[英]Angular Bootstrap uibModal not resolve attributs
Roles property not resolve in AngularJS bootstrap uiModel. Roles属性在AngularJS引导uiModel中无法解析。
var modalInstance = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'myModalContent.html',
controller: 'ModalInstanceCtrl',
size: 100,
resolve: {
roles: function () {
return $scope.roles;
}
}
});
See ngRepeat code which read the value of Roles and making dom elements. 请参阅ngRepeat代码,该代码读取Roles的值和制作dom元素。
<ul> <li ng-repeat="item in roles"> <a href="#" ng-click="$event.preventDefault(); selected.item = item">{{ item.name }}</a> </li> </ul>
Also error shows on console : Error: [$injector:unpr] Unknown provider: itemsProvider <- items <- ModalInstanceCtrl 控制台上也会显示错误:错误:[$ injector:unpr]未知提供程序:itemsProvider <-items <-ModalInstanceCtrl
After some sort of research I found that Angular only resolve items property in uiModel, so when user want to get values from other attributes then angular not respond properly. 经过某种研究,我发现Angular仅解析uiModel中的items属性,因此,当用户想要从其他属性获取值时,angular无法正确响应。
Find the updated code 查找更新的代码
var modalInstance = $uibModal.open({ animation: $scope.animationsEnabled, templateUrl: 'myModalContent.html', controller: 'ModalInstanceCtrl', size: 100, resolve: { items: function () { return $scope.userInfo; } } });
<ul> <li ng-repeat="item in items.role"> <a href="#" ng-click="$event.preventDefault(); selected.item = item">{{ item.name }}</a> </li> </ul>
Explaination : $scope.userInfo is the JSON object which contains the role key and role contains the list of role 说明 : $ scope.userInfo是一个JSON对象,它包含角色密钥,而角色则包含角色列表
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.