Angularjs 学习笔记
Angularjs
表单验证:https://www.w3xue.com/jsjq/angularjs/angularjs-validation.html
https://www.cnblogs.com/zml-java/p/5644260.html
表单验证后回调:https://blog.csdn.net/dengboz0910/article/details/53082772
factory vs service vs provider:https://www.oschina.net/translate/angularjs-factory-vs-service-vs-provider
select控件:https://m.runoob.com/angularjs/angularjs-select.html
$q和promise:https://www.cnblogs.com/xing901022/p/4928147.html
自己理解:
1、什么时候需要用promise?
当服务提供方想要自己提供的服务在执行成功后/失败后/值变化以后触发服务调用方相应的回调函数时,使用之。
2、使用方法
由服务提供方在服务方法的逻辑中使用$q.deffer()创建一个deffer对象。在服务逻辑执行成功/失败/关键值改变以后分别调用deffer的resolve(value)/reject(data)/notify(data)方法,并在服务逻辑的最后使用deffer.promise()方法返回promise对象。服务调用方调用了服务方法以后直接.then(),then方法里可以传三个回调函数,这三个回调函数分别在deffer的resolve(value)/reject(data)/notify(data)方法执行后自动被调用。第二个回调函数也会在resolve执行失败以后调用。
3、补充
3.1 deffer的三个方法可以单独使用,then方法也不一定必须传三个回调函数,也可以传一个或者两个回调函数,then方法返回promise对象,所以可以连续.then()。
3.2 promise还有两个方法catch()和finally()。
3.3 deffer的所谓关键值改变notify方法其实就是方便开发人员灵活应用的一种回调场景。只要你打算在编写的服务代码的某处触发调用者的回调函数,就使用notify,当然,其实resolve和reject也是可以灵活使用。
4、deffer只是$q的一种功用。
Angularjs里的定时器和循环执行:
https://www.cnblogs.com/moli-/p/5827618.html
定时器的销毁:https://blog.csdn.net/liwusen/article/details/52138882
如何在主页面和ngdialog之间传递参数?
https://segmentfault.com/q/1010000007149580
1、必须做的步骤:ngDialog的scope:$scope
2、如何向主页面的$scope赋值:在ngDialog的controller中,使用$scope.$parent即等价于主页面中的$scope
3、如何从主页面的$scope中取值?直接使用主页面中$scope的变量即可。
参考资料:https://github.com/likeastore/ngDialog
使用$watch监听对象的改变:
http://www.zymseo.com/386.html
https://www.cnblogs.com/yg_zhang/p/4799369.html
$scope.$watch('targetObj', function(n, o){
XXXXXX
}, true);
n代表新值,o代表老值,如果被监听的是一个对象,则第三个参数必须带,且是true。
id问题:
$apply的使用:
$http在post时,参数params和data有何区别?以及其他参数的学习: