我正在使用AngularJs 1.5版。我创建了一个简单的组件来添加评论
angular.module('myapp')
.component('comments', {
templateUrl: "views/component/comments.html",
bindings: { },
controller: function ($http, $rootScope, $interval, $scope) {
var ctrl = this
ctrl.users = $rootScope.users;
console.log(ctrl.users); // This variable had value
}
})
然后,在视图中,我放置一个按钮来显示Popover
<button popover-is-open="$ctrl.userListPopoverStatus" popover-title="Add User" uib-popover-template="'views/popover/order_select_user.html'" popover-placement="top" class="btn btn-primary" ng-model="$ctrl.users"><i class="fa fa-fw fa-tags"></i></button>
我的Popover模板
<div class="row margintop-10">
<form class="form-horizontal">
<table class="table table-striped small_table_user">
<tr>
<td>
<input type="text" class="form-control" ng-model="$ctrl.searchText" placeholder="Search user" />
</td>
</tr>
<tr ng-repeat="user in $ctrl.users | filter:$ctrl.searchText">
<td ng-click="pickUserProcess(user.id)">{{user.name}}</td>
</tr>
</table>
</form>
</div>
但是好像,Bootstrap Popover无法访问$ ctrl.users变量,因此列表用户根本不显示。我该如何解决这个问题?
答案 0 :(得分:0)
我猜这是因为角点问题造成的。 尝试:
var ctrl = {}
ctrl.users = $rootScope.users;