• angularjs 笔记



    控制台调试
    angular.element($0).scope() $0~$4
    angular.element($("#controllerId")).scope()

    手动启动
    angular.element(document).ready(function(){
        //如果用以下方式可删除body的ng-app="MyApp"
        angular.bootstrap(document.body, ['MyApp'])
    });

    用ng-if代替ng-show


    ng-class以及ng-style通过判断赋值

    ng-class="{'state-error':!data.isValid}" 

    <div ng-init="isSelected=true" ng-class="{true:'selected', false:''}[isSelected]">ngClass
    </div>

    ng-style="{ color: data.color=='' || data.name=='活' ? '#fff' : '#F03EF0' }"

    整合underscore.js

    var underscore = angular.module('underscore', []);
        underscore.factory('_', function() {
            return window._; //Underscore must already be loaded on the page
        });
      
        var myApp = angular.module("MyApp", ["ngSanitize", "underscore"]);
        myApp.controller("TableCtrl", ["$scope", '_', function($scope, _) {        
            var init = function(){
                console.log(_.keys($scope));        
            };
            init();
        }]);


    依赖注入

    angualar.module('myModule', []).
    config(['depProvider', function(depProvider){
    ...
    }]).
    factory('serviceId', ['depService', function(depService) {
    ...
    }]).
    directive('directiveName', ['depService', function(depService) {
    ...
    }]).
    filter('filterName', ['depService', function(depService) {
    ...
    }]).
    run(['depService', function(depService) {
    ...
    }]);

  • 相关阅读:
    然乌湖
    邦达 八宿
    芒康
    巴塘
    禾尼乡 所波大叔
    世界高城 理塘
    相克宗 藏民家
    骑行川藏--新都桥&塔公草原
    d 3
    D2
  • 原文地址:https://www.cnblogs.com/dfg727/p/4019485.html
Copyright © 2020-2023  润新知