var el=$compile("HTML代码")(scope)
element.append(el) //element是插入带的容器
html中引入angularjs的方法:
1、在html的script标签中加入以下代码:
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
2、引入后调用示例:
<html ng-app="myNoteApp">
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>
<div ng-controller="myNoteCtrl">
<h2>我的笔记</h2>
<p><textarea ng-model="message" cols="40" rows="10"></textarea></p>
<p>
<button ng-click="save()">保存</button>
<button ng-click="clear()">清除</button>
</p>
<p>Number of characters left: <span ng-bind="left()"></span></p>
</div>
<script src="myNoteApp.js"></script>
<script src="myNoteCtrl.js"></script>
</body>
</html>
3、运行结果:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)