Angularjs 使用ControllerAs时,指令参数被重写
我试图使用一个具有不同参数值的指令,指令中第一个参数的值被第二个参数覆盖 这是我的父母Angularjs 使用ControllerAs时,指令参数被重写,angularjs,Angularjs,我试图使用一个具有不同参数值的指令,指令中第一个参数的值被第二个参数覆盖 这是我的父母 <div finals-match-row team="foo"></div> <div finals-match-row team="bar"></div> 这是指令 angular.module('ViewTournament') .directive('finalsMatchRow', function () { return {
<div finals-match-row team="foo"></div>
<div finals-match-row team="bar"></div>
这是指令
angular.module('ViewTournament')
.directive('finalsMatchRow', function () {
return {
bindToController: {
team: '@'
},
template: "<p>{{ctrl.team}}</p>",
controllerAs: 'ctrl',
controller: function () {
var ctrl = this;
}
}
});
angular.module('viewTornament')
.directive('finalsMatchRow',函数(){
返回{
bindToController:{
小组:“@”
},
模板:“{{ctrl.team}”,
controllerAs:'ctrl',
控制器:函数(){
var ctrl=this;
}
}
});
当我使用scope时,一切似乎都正常将指令更改为
directive('finalsMatchRow', function() {
return {
bindToController: true,
scope: {
team: '@'
},
template: "<p>{{ctrl.team}}</p>",
controllerAs: 'ctrl',
controller: function() {
var ctrl = this;
}
}
});
指令('FinalMatchRow',函数(){
返回{
bindToController:对,
范围:{
小组:“@”
},
模板:“{{ctrl.team}”,
controllerAs:'ctrl',
控制器:函数(){
var ctrl=this;
}
}
});
将指令更改为
directive('finalsMatchRow', function() {
return {
bindToController: true,
scope: {
team: '@'
},
template: "<p>{{ctrl.team}}</p>",
controllerAs: 'ctrl',
controller: function() {
var ctrl = this;
}
}
});
指令('FinalMatchRow',函数(){
返回{
bindToController:对,
范围:{
小组:“@”
},
模板:“{{ctrl.team}”,
controllerAs:'ctrl',
控制器:函数(){
var ctrl=this;
}
}
});
尝试将
bindToController:true,
添加到指令对象(您可以阅读更多)尝试将bindToController:true,
添加到指令对象(您可以阅读更多)