我有这个代码对我有用,就是当我按下输入时,我用输入中的新文本替换文本,问题是如果不加以替换
<div ng-app="myApp" ng-controller="myCtrl as model">
<input type="text" ng-model="c1ero" ng-cero="uno" >
<input type="text" ng-model="model.eae" ng-cero="dos" >
</div>
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 === 13) {
scope.$apply(function(){
scope.$eval(attrs.ngCero, {'event': event});
$parse(attrs.ngModel).assign(scope, '0, ');
console.log(attrs);
});
event.preventDefault();
}
});
};
return{
//controller: "myCtrl",
link: linkFunction
}
})