<body ng-app="myApp">
<div ng-controller="testCtrl">
<strong>Name: </strong>{{name}}<br>
<a dirt-pass-fun callback="changename">
</a>
</div>
<script>
var myApp = angular.module('myApp',[]);
myApp.controller("testCtrl", function($scope) {
this.nickname="ctrl1 nickname";
$scope.name="ctrl1";
$scope.modelOne = {
foo: 'Pascal'
};
$scope.changename = function(t) {
$scope.name+=t;
}
});
myApp.directive('dirtPassFun', function() {
return {
restrict: 'A',
scope: {
callback: '='
},
template: '<button ng-click="callback(\'i am man\')">Click</button>'
};
});
</script>
</body>
沒有留言:
張貼留言