bootstrap ui 模态中的 class 指令不编译
Directives as class in bootstrap ui modal do not compile
我试图在 windowClass 字段中将一个指令作为 class 传递,但它似乎没有被编译,因此没有调用该指令。
模态:
...
$modal.open({
templateUrl: 'modal.html',
scope: scope,
controller: 'myCtrl as controller',
backdrop: false,
windowClass: 'directive'
})
.result.then(function (data) {
// something
});
...
指令:
...
.directive('directive', function() {
return {
link: function(scope, element, attr) {
var modal = element;
console.log("directive called");
// real code goes there
}
};
});
...
使用此配置,永远不会调用该指令。
我目前正在使用一种解决方法,但我对此并不满意:
指令:
...
.directive('directive', function() {
return {
link: function(scope, element, attr) {
var modal = element.parent().parent().parent();
console.log("directive called");
// real code goes there
}
};
});
...
modal.html:
<div directive>
<!-- something -->
</div>
我发现了同样的问题
here but it doesn't have an answer other than my workaround, so I am reposting it with the appropriate tag: angular-ui-bootstrap as specified on the github repo,希望得到更好的回答。
我正在使用:
- angular v1.3
- angular-ui/bootstrap v0.13.0(最新版本)
更新:请参阅下面的评论。
目前,我们不重新编译该元素。相反,我们只是调用 $element.addClass
并传入用户指定的值 windowClass
。
但是,我们确实认为这可能有一个用例,如果您不介意,请输入一个新问题 here。
请link这个SOpost到新的issue。谢谢
我试图在 windowClass 字段中将一个指令作为 class 传递,但它似乎没有被编译,因此没有调用该指令。
模态:
...
$modal.open({
templateUrl: 'modal.html',
scope: scope,
controller: 'myCtrl as controller',
backdrop: false,
windowClass: 'directive'
})
.result.then(function (data) {
// something
});
...
指令:
...
.directive('directive', function() {
return {
link: function(scope, element, attr) {
var modal = element;
console.log("directive called");
// real code goes there
}
};
});
...
使用此配置,永远不会调用该指令。
我目前正在使用一种解决方法,但我对此并不满意:
指令:
...
.directive('directive', function() {
return {
link: function(scope, element, attr) {
var modal = element.parent().parent().parent();
console.log("directive called");
// real code goes there
}
};
});
...
modal.html:
<div directive>
<!-- something -->
</div>
我发现了同样的问题 here but it doesn't have an answer other than my workaround, so I am reposting it with the appropriate tag: angular-ui-bootstrap as specified on the github repo,希望得到更好的回答。
我正在使用:
- angular v1.3
- angular-ui/bootstrap v0.13.0(最新版本)
更新:请参阅下面的评论。
目前,我们不重新编译该元素。相反,我们只是调用 $element.addClass
并传入用户指定的值 windowClass
。
但是,我们确实认为这可能有一个用例,如果您不介意,请输入一个新问题 here。
请link这个SOpost到新的issue。谢谢