您的位置:首页 > Web前端 > AngularJS

Angular学习(7)- 模板2

2014-03-28 15:17 190 查看
示例:

<!DOCTYPE html>
<html ng-app="MyApp">
<head>
<title>Study 8</title>
<script type="text/javascript" src="js/angular.js"></script>
</head>
<body>
<hello>Robin</hello>
<test-template></test-template>

<script type="text/javascript">
var app = angular.module("MyApp", [], function() { });
app.directive("hello", function() {
return {
restrict: 'E',
template: "<div>Hello,<b ng-transclude></b></div>",
replace: true,
transclude : true
};
});

app.directive("testTemplate", function() {
return {
restrict: 'E',
templateUrl: "test.html",
replace: true
};
});
</script>

<script type="text/ng-template" id="test.html">
<div>Test Template</div>
</script>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: