Javascript AngularJS:加载视图后调用指令
我有一个奇怪的问题,用'dot1指令很难重现:Javascript AngularJS:加载视图后调用指令,javascript,angularjs,angularjs-directive,dotdotdot,Javascript,Angularjs,Angularjs Directive,Dotdotdot,我有一个奇怪的问题,用'dot1指令很难重现: .directive('dotdotdot', ['$timeout', function($timeout) { return { restrict: 'A', link: function(scope, element) { scope.$evalAsync(function () { element.dotdotdot({ watch: true,
.directive('dotdotdot', ['$timeout', function($timeout) {
return {
restrict: 'A',
link: function(scope, element) {
scope.$evalAsync(function () {
element.dotdotdot({
watch: true,
wrap: 'letter'
});
});
angular.element('.modal').on('shown.bs.modal', function() {
angular.element('.modal-nonedit-dotdotdot').dotdotdot({
watch: true,
wrap: 'letter'
});
});
}
};
}]);
但有时它在从服务器获取我的范围变量之前被调用,所以它的行为真的很奇怪
我有一些想法,我必须使用超时
但是我怎么用呢?因为如果我设定
$timeout(function() {
element.dotdotdot({
watch: true,
wrap: 'letter'
});
});
它的工作方式也很奇怪
如何正确设置指令的执行?我看不到此代码中您在哪里访问任何作用域属性?请共享html