zoukankan      html  css  js  c++  java
  • $compile

    <html ng-app="compile">
        
        <head>
            <script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
        </head>
        <body>
            <div ng-controller="compileCtrl">
                <ts-s>
                    
                </ts-s>
            </div>
        <script type="text/javascript">
            var app = angular.module("compile", []);
            app.controller("compileCtrl", function($scope){
                $scope.updateModuleInfo = function( module ){
                    console.log("module : " + module);
                }
            });
            app.directive('tsS', function($compile) {  
                return {  
                    //template:"<input type='text' ng=model='sampleData'/> {{sampleData}} <br/>"  
                    link: function(scope, element, atts, controller) { 
                        var module = {
                            id : "11",
                            name : "john"
                        } 
                        var markup = "<input type='text' ng-model='sampleData' ng-change='updateModuleInfo(module)'/> {{sampleData}} <br/>";
                        element.html(markup);
                        scope.module = module;//向scope中插入module对象
                        $compile(element.contents())(scope);  
                    }  
                };  
            });
    
    
        </script>
        </body>
    </html>

    em:

    scope.module = module;//向scope中插入module对象

    renderRow : function(nRow, aData, iDataIndex, anHidden){
        var link = $compile('<a href="" ng-click="updateModuleInfo(aData)> 编辑 </a>' );
        var scope = $scope.$new(false);//新建子作用域
        var node = link(scope);
        scope.aData = aData;//向scope中插入aData对象
        if (true) {
            $(--).html(node)
        }
    }
  • 相关阅读:
    2012 Multi-University #8
    2016"百度之星"
    Codeforces Round #352 (Div. 2)
    数位DP CF 55D Beautiful numbers
    数位DP GYM 100827 E Hill Number
    2012 Multi-University #9
    2012 Multi-University #10
    java生成指定范围的随机数
    MySql查询时间段的方法
    eclipse报错GC overhead limit exceed,卡顿
  • 原文地址:https://www.cnblogs.com/zyjzz/p/5744640.html
Copyright © 2011-2022 走看看