我有这样的指示
app.directive('clipChat', ClipChat);
function ClipChat() {
var strfin ='*';
var chatTemplate = '<div ng-repeat="message in newarr"> <span ng-if="message.content.slice(-1)==message.star" ng-click="makeitTodo(message)">i <i class="fa fa-mail-forward "></i></span> '+ '</div>' ;
var directive = {
restrict: 'EA',
template: chatTemplate,
replace: true,
scope: {
messages: "=",
idSelf: "=",
idOther: "=",
},
link:function ($scope) {
Run Code Online (Sandbox Code Playgroud)
//等等
当我单击控制器内的span元素时,我想调用函数makeitTodo ..
我测试过如下.
app.controller('ChatCtrl', ["$scope",function($scope){
$scope.makeitTodo = function(a){
alert(a);
}
}])
Run Code Online (Sandbox Code Playgroud)
但它不起作用.请帮助我.
javascript angularjs angularjs-directive angularjs-controller