[英]Angular - ng-click doesn't work
在我看来,我有:
<button ng-click="getPerson()">test</button>
<ul>
<li ng-repeat="person in persons">{{ person.name + ' - ' + person.username }}</li>
</ul>
ul-part工作正常,但单击按钮时不调用getPerson()? 警报未显示。
我的控制器:
app.controller('personsController', function ($scope, personsService) {
getPersons();
function getPersons() {
personsService.getPersons()
.success(function (persons) {
$scope.persons = persons;
})
.error(function (error) {
$scope.status = 'Error: ' + error.message;
});
}
function getPerson() {
alert('tst');
}
});
难道我做错了什么?
该函数需要在$scope
:更改:
function getPerson() {
至:
$scope.getPerson = function() {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.