我正在使用语义 UI 来使用 AngularJS 格式化我的网站。我的控制器已设置好并且运行良好。但它只是不喜欢我的代码的这一部分:
<div class="ui piled feed segment">
<h2 class="ui header">
Comments
</h2>
<div class="event" ng-repeat = "comment in comments | reverse">
<div class="ui green horizontal label">
{{comment.user}}
</div>
<div class="content">
<div class="summary" ng-click="doSomething()">
{{ comment.content }}
</div>
</div>
</div>
</div>
这是 AngularJS 代码:
$scope.doSomething = function(){
alert('blah');
};
基本上,我想在单击内容时执行 doSomething() 。但由于某种原因它不起作用并给出以下错误:
TypeError: undefined is not a function
at http://localhost:3000/js/lib/angular.min.js:65:98
at http://localhost:3000/js/lib/angular.min.js:72:222
at http://localhost:3000/js/lib/angular.min.js:144:140
at Object.e.$eval (http://localhost:3000/js/lib/angular.min.js:88:347)
at Object.e.$apply (http://localhost:3000/js/lib/angular.min.js:88:454)
at HTMLAnchorElement.<anonymous> (http://localhost:3000/js/lib/angular.min.js:144:122)
at HTMLAnchorElement.n.event.dispatch (http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js:3:8066)
at HTMLAnchorElement.r.handle (http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js:3:4774)
我很不确定这个错误意味着什么,因为通常“未定义”意味着函数定义有问题,但在这里我没有发现任何问题。我在这个应用程序的其他地方的 ng-repeat 里面有 ng-click,它工作正常。是因为语义 UI 吗?