Angular调用父Scope的函数

app.directive('toggle', function(){
return {
restrict: 'A',
template: '<a ng-click="f()">Click Me</a>',
replace: true,
scope: {
toggle: '&'
},
controller: function($scope) {
$scope.toggleValue = false;
$scope.f = function() {
$scope.toggleValue = !$scope.toggleValue;
$scope.toggle({message: $scope.toggleValue});
};
}
};
});

You can use like this:

<div toggle="parentToggle(message)"></div>
上一篇:jquery 操作服务端控件,select 控件


下一篇:.Net Mvc3框架调用服务端控件解决方案