我试图从链接函数添加一个ng-class属性到自定义指令.但是在添加ng-class属性后使用编译功能时,会抛出类似"RangeError:超出最大调用堆栈大小"的错误
请参阅下面的代码
MyApp.directive('twinField',function($compile){
return {
restrict:'A',
require:'ngModel',
scope:{
fval:'='
},
link:function(scope,ele,attr,ctrl){
ctrl.$validators.compareTo=function(val){
//alert(scope.fval)
return scope.fval==val
}
scope.$watch('fval', function(newValue, oldValue, scope) {
ctrl.$validate()
});
ele.attr("ng-class","addForm.cpassword.$error.compareTo?'errorpswd':''")//=""
$compile(ele)(scope);
}
}
Run Code Online (Sandbox Code Playgroud)
})
当我直接在html中添加ng-class时它正在工作.
我正在尝试使用hyper作为提供程序运行vagrant,遵循本指南.但当我运行'vagrant up'时,我收到以下错误:
$ vagrant up
C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/psych.rb:370:in `parse': (<unknown>): found a tab character that violate intendation while scanning a plain scalar at line 21 column 7 (Psych::SyntaxError)
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/psych.rb:370:in `parse_stream'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/psych.rb:318:in `parse'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/psych.rb:245:in `load'
from E:/www/Homestead/Vagrantfile:20:in `block in <top (required)>'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.3/lib/vagrant/config/v2/loader.rb:37:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.3/lib/vagrant/config/v2/loader.rb:37:in `load'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.3/lib/vagrant/config/loader.rb:113:in `block (2 levels) in load'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.3/lib/vagrant/config/loader.rb:107:in `each'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.3/lib/vagrant/config/loader.rb:107:in `block in load'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.3/lib/vagrant/config/loader.rb:104:in `each'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.3/lib/vagrant/config/loader.rb:104:in `load'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.3/lib/vagrant/vagrantfile.rb:28:in `initialize'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.3/lib/vagrant/environment.rb:740:in `new'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.3/lib/vagrant/environment.rb:740:in `vagrantfile'
from …Run Code Online (Sandbox Code Playgroud)