我有一个迭代的项目表。现在,当您点击某个项目时,没有任何事情发生。经过一些测试,我发现ngClick指令没有触发。值得一提的是,我在页面上的其他Angular工作得很好(同一个控制器)。
HTML:
<form name="areaForm" ng-submit="createArea(areaData)">
<div id="name-group" class="form-group">
<label>Name</label>
<input type="text" name="name" class="form-control" placeholder="Area Name" ng-model="areaData.name" required/><br />
<!-- Group search -->
<label>Department</label>
<input name="group" id="group-search-box" class="form-control" type="text" placeholder="Begin typing a department..." ng-focus="focus = true" required>
<!-- Group filter results -->
<table ng-show="focus">
<tr class="group-search-result" ng-repeat="group in groups | filter : groupSelect" id="{{ group.id }}">
<td ng-click="setSelectedGroup(group.id)">{{ group.name }}</td>
</tr>
</table>
</div>
<button type="submit" class="btn btn-default">Create</button>
</form>
Angular.js
$scope.setSelectedGroup = function(group){
console.log(group);
getElementById('#group-search-box').setAttribute('value', group.name);
};
$scope.selectGroup = function(group){
var thisGroup = $filter('filter')($scope.groups, {id: group})[0];
};