Angularjs 如何将作用域传递给AngularStrap$Alert?
我只是角度方面的新手,我正在使用angularstrap制作自定义警报,并使用ng repeat在对象上重复数据 这是我的角度代码Angularjs 如何将作用域传递给AngularStrap$Alert?,angularjs,angular-strap,Angularjs,Angular Strap,我只是角度方面的新手,我正在使用angularstrap制作自定义警报,并使用ng repeat在对象上重复数据 这是我的角度代码 让alertExcpetion=$alert({ 位置:'右上', 键入:“警告”, 秀:没错, 键盘:正确 模板:“alert.template.html” }); 这是alert.template.html &时代; {{someScopeTitle}} {{student.id} {{student.fullname} 加载后。警报为空,因为它未读取范围
让alertExcpetion=$alert({
位置:'右上',
键入:“警告”,
秀:没错,
键盘:正确
模板:“alert.template.html”
});
这是alert.template.html
&时代;
{{someScopeTitle}}
{{student.id}
{{student.fullname}
加载后。警报为空,因为它未读取范围。是否有任何可能的方法将范围传递给angularstrap的$alert
角带版本v2.1.6-2015-01-11根据,您可以将控制器
和控制器
选项传递到警报模式
另一个.controller.js
let alertExcpetion = $alert({
placement: 'top-right',
type: 'warning',
show: true,
keyboard: true
template: 'alert.template.html',
controller: 'ModalController',
controllerAs: 'ctrl'
});
.controller('ModalController',...
$scope.someScopeTitle = 'title';
...
let alertExcpetion = $alert({
placement: 'top-right',
type: 'warning',
show: true,
keyboard: true
template: 'alert.template.html',
scope:$scope
});
modal.controller.js
let alertExcpetion = $alert({
placement: 'top-right',
type: 'warning',
show: true,
keyboard: true
template: 'alert.template.html',
controller: 'ModalController',
controllerAs: 'ctrl'
});
.controller('ModalController',...
$scope.someScopeTitle = 'title';
...
let alertExcpetion = $alert({
placement: 'top-right',
type: 'warning',
show: true,
keyboard: true
template: 'alert.template.html',
scope:$scope
});
alert.template.html
...
<div class="title">
{{ ctrl.someScopeTitle }}
</div>
...
。。。
{{ctrl.someScopeTitle}
...
将范围添加到您的警报呼叫中
js
let alertExcpetion = $alert({
placement: 'top-right',
type: 'warning',
show: true,
keyboard: true
template: 'alert.template.html',
controller: 'ModalController',
controllerAs: 'ctrl'
});
.controller('ModalController',...
$scope.someScopeTitle = 'title';
...
let alertExcpetion = $alert({
placement: 'top-right',
type: 'warning',
show: true,
keyboard: true
template: 'alert.template.html',
scope:$scope
});
已经尝试过了,但是我的IDE错误地告诉我,'scope'不存在于'IAlertOptions'类型中。
@Liky你能创建一个plunker示例吗?我只是使用了一个过时的角度带,这就是我出错的原因。使用了你的代码,它成功了。谢谢很高兴能帮助您@Likyi我在控制器上遇到了错误,顺便说一句,我使用的是angular strap v2.1.6版。是不是因为我的版本中没有它?