var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
$scope.changeName = (function(newName){
$scope.name = newName;
// Do you stuff here.
});
});
app.directive("remove", function() {
return {
link: function(scope, elm, attrs) {
elm.bind('click', function(e) {
console.log(attrs.remove);
scope.$apply(function(){
scope.$eval(attrs.remove);
});
});
}
};
}
);
<!doctype html>
<html ng-app="plunker" >
<head>
<meta charset="utf-8">
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css">
<script src="http://code.angularjs.org/1.1.4/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
Hello {{name}}!
<button remove="changeName('Human')">Click Me</button>
</body>
</html>
/* Put your css in here */