为什么ng-model不是从指令内部绑定到变量的输入?

时间:2015-10-19 11:23:03

标签: javascript angularjs

https://stackoverflow.com/questions/10428510/how-to-start-launch-application-at-boot-time-android

index.html

<!DOCTYPE html> <html ng-app="myApp"> <head> <script src="js/angular.js" type="text/javascript"></script> <script src="js/app.js" type="text/javascript"></script> </head> <body> <input test type="text"/><br/> myName1: {{myName}} </body> </html>

app.js

虽然我已将var app = angular.module('myApp',[]); app.directive('test',function($compile){ return{ terminal:true, priority:1000000, link:function($scope,$element){ var cloned = $element.clone(); cloned.removeAttr("test"); cloned.attr("ng-model","myName1"); var clonedElement = $compile(cloned)($scope); $element.after(clonedElement); } }; }); 属性添加到ng-model但是当我在输入字段中键入值时,它不会显示在视图中,因为它通常在ng-model中出现。为什么cloned无法将我正在输入的文字绑定到ng-model?我错过了什么?

0 个答案:

没有答案