AngularJS-创建使用ng-model的指令
我正在尝试创建一个指令,该指令将创建与创建指令的元素具有相同ng-model的输入字段。 到目前为止,这是我想到的: 的HTML <!doctype html> <html ng-app="plunker" > <head> <meta charset="utf-8"> <title>AngularJS Plunker</title> <link rel="stylesheet" href="style.css"> <script>document.write("<base href=\"" + document.location + "\" />");</script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js"></script> <script src="app.js"></script> </head> <body ng-controller="MainCtrl"> This scope value <input ng-model="name"> <my-directive ng-model="name"></my-directive> </body> </html> 的JavaScript var app = angular.module('plunker', []); app.controller('MainCtrl', function($scope) { …