0
我試圖訪問範圍的值,但它顯示爲未定義,我需要告訴我用戶插入的值。範圍未定義在指令
我的HTML
<div ng-app="myApp" ng-controller="myCtrl as model">
<input type="text" ng-model="model.cero" ng-cero="">
</div>
在JS
angular
.module("myApp",[])
.controller('myCtrl', function($scope){
var model=this;
})
.directive ('ngCero', function($parse){
var linkFunction =function(scope, element, attrs){
element.bind("keypress", function(event) {
if(event.which === 44 || event.which === 13) {
console.log($parse(attrs.format));
}
});
};
return{
restrict : 'A',
}
})