zoukankan      html  css  js  c++  java
  • angularjs 服务供应商

    <!DOCTYPE HTML>
    <html ng-app="myApp">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
    <style>
    #parent div{ 300px; height:500px; border:1px #000 solid; margin:20px;}
    #parent ul{ 200px; position:fixed; top:0; right:0;}
    </style>
    <script src="angular.min.js"></script>
    <script>
    //供应商:为对应的服务初始化相关配置
    
    
    var m1 = angular.module('myApp',[]);
    //interpolateProvider是interpolate(插值)的服务供应商,scopeProvider是scope的服务供应商。供应商的操作要在config里面写。
    m1.config(['$interpolateProvider',function($interpolateProvider){    
        //不用{{}}用@@@@。
        $interpolateProvider.startSymbol('@@');
        $interpolateProvider.endSymbol('@@');    
    }]);
    
    m1.controller('Aaa',['$scope','$interpolate',function($scope,$interpolate){    
        $scope.$watch('body',function(newBody){        
            if(newBody){
                var temp = $interpolate(newBody);
                $scope.showText = temp({ name : $scope.name });            
            }        
        });    
    }]);
    
    </script>
    </head>
    
    <body>
    <div ng-controller="Aaa">
        <input type="text" ng-model="name">
        <textarea ng-model="body">
        </textarea>
        <p>@@showText@@</p>
    </div>
    </body>
    </html>
    <!DOCTYPE HTML>
    <html ng-app="myApp">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
    <style>
    #parent div{ 300px; height:500px; border:1px #000 solid; margin:20px;}
    #parent ul{ 200px; position:fixed; top:0; right:0;}
    </style>
    <script src="angular.min.js"></script>
    <script>
    
    var m1 = angular.module('myApp',[]);
    //$logProvider是$log服务的供应商。
    m1.config(['$interpolateProvider','$logProvider',function($interpolateProvider,$logProvider){
        $logProvider.debugEnabled(false);//禁用debug,则下面就不能打印hello.
    }]);
    
    m1.controller('Aaa',['$scope','$log',function($scope,$log){
        $log.debug('hello');
    }]);
    
    </script>
    </head>
    
    <body>
    <div ng-controller="Aaa">
       
    </div>
    </body>
    </html>
    <!DOCTYPE HTML>
    <html ng-app="myApp">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
    <style>
    #parent div{ 300px; height:500px; border:1px #000 solid; margin:20px;}
    #parent ul{ 200px; position:fixed; top:0; right:0;}
    </style>
    <script src="angular.min.js"></script>
    <script>
    
    var m1 = angular.module('myApp',[]);
    
    //$anchorScrollProvider是anchorScroll的服务供应商,
    m1.config(['$anchorScrollProvider',function($anchorScrollProvider){
        $anchorScrollProvider.disableAutoScrolling();//禁止锚点跳转。
    }]);
    
    m1.controller('Aaa',['$scope','$location','$anchorScroll',function($scope,$location,$anchorScroll){
        $scope.change = function(id){    
            $location.hash(id);
            $anchorScroll();
        };
    }]);
    
    </script>
    </head>
    <body>
    <div id="parent" ng-controller="Aaa">
        <ul>
            <li ng-repeat="id in [1,2,3,4,5]" ng-click="change('div'+id)">{{id}}aaaaaaaaaa</li>
        </ul>
        <div ng-repeat="id in [1,2,3,4,5]" ng-attr-id="div{{id}}">{{id}}</div>
    </div>
    </body>
    </html>
  • 相关阅读:
    base64是什么东东,base64 图片显示,在线编辑器
    中文字符 与 十六进制Unicode编码 相互转换
    全面理解Python中self的用法
    Python之使用元类MetaClass
    Python之MySQL数据库连接驱动aiomysql的使用
    Python实战网站开发:Day2编写Web App骨架
    Python实战网站开发:Day3编写ORM
    Python之MySQL数据库连接驱动pymysql的使用
    【CV基础】为什么一些深度学习的图像预处理使用mean=[0.485, 0.456, 0.406] and std=[0.229, 0.224, 0.225]来正则化?
    与人合作创业是一门大艺术(转)
  • 原文地址:https://www.cnblogs.com/yaowen/p/5745917.html
Copyright © 2011-2022 走看看