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