angularjs动态添加节点时,绑定到$scope中

<html>
<head>
<meta charset="utf-8"/>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/angular.js/1.6.8/angular.min.js"></script> <script>
angular.module("testApp", []).controller("testController", function($scope, $compile) {
$scope.a = "111";
$scope.b = "222"; var node = "<input id='input2' ng-model='b' />";
$("#input1").after(node); var linkFn = $compile(node);
var content = linkFn($scope);
$("#input2").after(content);
});
</script>
</head>
<body ng-app="testApp">
<div ng-controller="testController">
<input id="input1" ng-model="a" />
</div>
</body>
</html>

运行结果:

angularjs动态添加节点时,绑定到$scope中

上一篇:javascript判断是否是微信内嵌浏览器访问


下一篇:为11.2.0.2 Grid Infrastructure添加节点