zoukankan      html  css  js  c++  java
  • Angularjs[26]

    • templateUrl: 加载模板所要使用的 URL。
    • 可以加载当前模板内对应的 text/ng-template script id。
    • 在使用 chrome 浏览器时,“同源策略”会阻止 chorme 从 file:// 中加载模板,并显示一个“ Access-Control-Allow-Origin ”不允许源为 null,可以把项目放在服务器上加载,或者给 chorme 设置一个标志位,命令为:chorme-allow-file-access-from-files。
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <div ng-app="myApp">
    
            <script type="text/ng-template" id="customTags2">
                <div>
                    hello {{name}}
                </div>
            </script>
    
            <div ng-controller="firstController">
                <custom-tags></custom-tags>
                <custom-tags2></custom-tags2>
            </div>
    
        </div>
    
    <script type="text/javascript" src="../../vendor/angular/angularjs.js"></script>
    <script type="text/javascript" src="app/index.js"></script>
    </body>
    </html>
     <div>{{name}}</div>
    var myApp = angular.module('myApp',[])
    .directive('customTags',function () {
        return{
            restrict: 'ECAM',
            templateUrl:'tmp/other.html',
            replace: true
        }
    })
    .directive('customTags2',function () {
        return{
            restrict: 'ECAM',
            templateUrl:'customTags2',
            replace: true
        }
    })
    .controller('firstController',['$scope',function ($scope) {
        $scope.name = 'Alrale';
    }]);

  • 相关阅读:
    面试经验链接汇集
    258. Add Digits
    192. Word Frequency(shell)
    6、字符串循环对角线结构ZigZag Conversion
    5、最长回文子串Longest Palindromic Substring
    idea常用的快捷命令
    JAVA传输概念
    UUID随机字符串
    Bean的加载
    默认标签的解析过程(三)parseDefaultElement
  • 原文地址:https://www.cnblogs.com/bky-1083/p/6359086.html
Copyright © 2011-2022 走看看