zoukankan      html  css  js  c++  java
  • 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) {
    ...
    }]);

  • 相关阅读:
    大小写英文字母表
    JSP作业
    第六次作业
    第五次作业
    第二次作业
    JSP第一次作业
    作业9
    作业八
    作业7
    第二次作业
  • 原文地址:https://www.cnblogs.com/dfg727/p/4019485.html
Copyright © 2011-2022 走看看