2016年4月4日

[TOC]

2016年4月4日

angularjs

$scope.$watch($scope.sum,function(newVal,oldVal){
        //console.log(newVal);
        //console.log(oldVal);

        $scope.iphone.fre = newVal >= 100 ? 0 : 10;

    });

三个参数: 第一个是监听的参数,第二个触发时执行的函数,有两个参数,旧值以及新值;第三个是为true时整体监听。

var m1 = angular.module('myApp',[]);
m1.controller('Aaa',function($scope){
    $scope.name = 'hello';
});

//上下意思一样
var m1 = angular.module('myApp',[]);
m1.controller('Aaa',['$scope',function($s){
    $s.name = 'hello';
}]);
  • angular.bind()

改变this的指向。

  • angular.copy()

拷贝对象。

a全部拷贝覆盖b;

  • angular.extend()

拷贝继承,不覆盖。

  • angular.equals()

判读两个变量是否相等。

  • angular.forEach

遍历循环

  • angular.identity/noop()

返回调用的参数。

  • angular.lowercase/uppercase()

字符串转成大写或者小写。

  • angular.element()

可以进一步使用jQuery的方式调用。

  • 动态初始化

点击后显示。

  • angular.injector()

注册器,内部使用。

低分段

css

使用语义化方式为CSS命名可以像这样:

http://blog.bingo929.com/CSS-coding-semantic-naming.html

Last updated

Was this helpful?