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) {
    ...
    }]);

  • 相关阅读:
    26个精选的JavaScript面试问题
    用js实现随机选取10–100之间的10个数字,存入一个数组,并排序
    小程序布局中class='container'的bug
    PHP接收数据数据包的几个方式
    LINUX命令
    VMware的下载安装
    php中Sessions
    php中Cookies
    php文件上传
    php文件处理
  • 原文地址:https://www.cnblogs.com/dfg727/p/4019485.html
Copyright © 2011-2022 走看看