0
我在我的簡單指令中使用了require: '^form'
。在指令模板中使用角度表格
然後我試圖在ng-show中使用這個表單,但它似乎不起作用。
注意:我不想將表單名稱作爲屬性傳遞。
任何人都可以看到我要去哪裏錯了嗎?我只希望消息在表單無效時顯示。
angular.module('xxx').directive('errorWall', errorWall);
function errorWall() {
return {
restrict: 'E',
require: '^form',
scope: {},
link: (scope, elm, attrs, frm) => {
scope.formCtrl = frm;
},
template: '<div ng-show="formCtrl.$invalid">You have error messages.</div>'
};
}
當你在鏈接功能中放置一個斷點時,你會看到什麼? –