【发布时间】:2016-11-22 00:05:19
【问题描述】:
我一直在苦苦挣扎,到处在谷歌上搜索,我无法想象为什么这个指令没有更新我的控制器 $scope 值: 指令:
app.directive('ingFormField', function () {
return {
restrict: "E",
scope: {
value: "=",
fieldName: "@",
fieldLabel: "@"
},
div class="form-group">'+
' <label for="{{fieldName}}" class="control-label">{{fieldLabel}}:</label>'+
' <input ng-model="value" class="form-control" type="text" name="{{fieldName}}" id="{{fieldName}}" />' +
'</div>'
};
});
在 HTML 中使用:
<ing-form-field field-name="Order" field-label="Order" ng-model="lateral.Order"></ing-form-field>
我的控制器“横向”的对象:
$scope.lateral = {Order: "01", Name: "Person"}
我已经尝试了 StackOverflow 中关于使用链接函数更新控制器中的值的一些函数 $scope 具有相同的输出:从 $scope 到指令的值正在工作,但指令输入字段的任何更改都不起作用更新 $scope 对象“横向”
【问题讨论】:
-
您能否在放置此指令的位置添加 html 父代码。
标签: javascript angularjs angularjs-directive