我使用语义UI来格式化我的网站与AngularJS。我的控制器已经建立并运行良好。但它只是不喜欢我的这部分代码:ng-click不工作 - TypeError:undefined不是函数
<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-click在ng-repeat里面,在这个应用程序中的任何地方,它工作正常。是因为语义UI吗?
它不会这样的,首先你要在你的HTML – 2014-10-30 07:06:54
哦分配NG-的应用程序,这只是我的代码片段。应用程序,模块,控制器,一切都很好定义。 – 2014-10-30 07:08:13
你可以试一下小提琴演示吗? – 2014-10-30 07:09:17