2
在下面的代码中,如何将输入字段的ng-model
属性链接到this.test
变量。Formly - 如何从内嵌模板访问控制器属性
class NewComponent {
constructor() {
this.test = 'test';
this.fields = [
{
template:
'\
<div class="form-group">\
<input ng-model="test" type="text" class="form-control">\
</div>\
'
}
]
}
}
angular.module('app')
.component('NewComponent', {
templateUrl: 'new.html',
controller: NewComponent,
controllerAs: 'New'
});
我试过$ctrl.test
和New.test
....没什么!
如果它是一个angular2,请使用[(ngModel)]和angular1.5然后$ ctrl.test – varit05
这是角1.5。我试过$ ctrl,但它不工作...我添加了一些代码... – Mika
看看这个小提琴:https://plnkr.co/edit/eeUULQ1YrLhsQvSuA0fD?p=preview – varit05