美文网首页
指令缓存

指令缓存

作者: 幸福幸福幸福 | 来源:发表于2017-03-21 11:50 被阅读37次

    指令的本质其实是一个替换的过程。
    compile阶段进行标签的解析和变换,link阶段进行数据绑定等操作

    指令缓存

      var app = angular.module('app',[]);
        //注射器加载完所有模板时,此方法执行一次,缓存一下。以便在多个地方使用
        app.run(function($templateCache){
            $templateCache.put("hello.html","<div>Hello everyone!!</div>")
        }).directive("hello",function($templateCache){
            return {
                restrict : "ACEM",
                templateUrl : "hello.html",
                replace : true
            }
        })

    相关文章

      网友评论

          本文标题:指令缓存

          本文链接:https://www.haomeiwen.com/subject/rulggttx.html