Angular学习(7)- 模板2

示例:

<!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>

 

posted @ 2014-03-28 15:17  横渡  阅读(439)  评论(0编辑  收藏  举报