• AngularJs练习Demo6


    @{
        Layout = null;
    }
    
    <!DOCTYPE html>
    
    <html>
    <head>
        <meta name="viewport" content="width=device-width" />
        <title>Index6</title>
        <script type="text/javascript" src="~/Scripts/angular.js"></script>
        <script src="~/Scripts/angular-sanitize.js"></script>
    </head>
    <body>
        <div ng-app="myApp">
            <div ng-controller="firstController">
                <div ng-bind="text">ng-bind只能绑定一个</div>
                <div ng-bind-template="{{text}}{{name}}">ng-bind-template可以绑定多个</div>
                <div  ng-bind-html="h2">ng-bind-html 依赖sanitize插件依赖ngSanitize也可以通过使用$sce服务</div>
                <div ng-bind-html="detailContent()"></div>
                <div ng-repeat="innerList in list" ng-init="outerIndex=$index">
                    <div ng-repeat="value in innerList" ng-init="innerIndex=$index">
                        <span>list[{{outerIndex}}][[{{innerIndex}}]]={{value}}; </span>
    
                    </div>
                </div>
                <div>
                    <input type="text" ng-model="name" ng-model-options="{updateOn:'blur'}" />
                    {{name}}
    
                </div>
            </div> 
        </div>
        <script type="text/javascript">
            var app = angular.module("myApp", ['ngSanitize']);
            app.controller("firstController", function ($scope,$sce) {
                $scope.text = "PhoneGap中文网";
                $scope.name = "张三";
                $scope.h2 = "<h2>这是H2</h2>";
                $scope.detailContent = function () {
                    return $sce.trustAsHtml("<H1>使用ng的$sce来解析HTML</H1>");//记得写return
                };
                $scope.list = [['a','b'],['c','d']];
            });
    
        </script>
    </body>
    </html>
    

      

  • 相关阅读:
    OCP-1Z0-053-V12.02-40题
    OCP-1Z0-053-V12.02-255题
    OCP-1Z0-053-V12.02-407题
    OCP-1Z0-053-V12.02-298题
    OCP-1Z0-053-V12.02-38题
    OCP-1Z0-053-V12.02-274题
    OCP-1Z0-053-V12.02-159题
    OCP-1Z0-053-V12.02-406题
    OCP-1Z0-053-V12.02-369题
    OCP-1Z0-053-V12.02-610题
  • 原文地址:https://www.cnblogs.com/sumg/p/5605347.html
Copyright © 2020-2023  润新知