探索项目ing
1、angular.element()
的用法
引用jQuery的前提下,和$用法基本相同:angular.element('#').html()
例如:
angular.element('#test').html()
angular.element('#test').focus()
2.AngularJS方法 —— angular.bootstrap
简单来说,就是手动加载模块到DOM上,在DOM上使用ng-app
是自动加载
学习公司的实体书
1.使用$watch
监控数据模型的变化,
值,回调
// 切换时区触发
$scope.$watch("oSettingTimeInfo.szTimeZone", function () {
if (_dtDeviceTime !== null) {
service.updateSelectTime();
}
});
2.ui.config.js
相当于web4.0里的自定义指令包,包括表单校验,slider初始化,switch切换,都是通过这个库实现的。
是通过.directive()
方法定义自定义指令的
ng-change
指令(web4.0本项目未用到过,应该是有封装相应的自定义指令),意思是一般只用于表单,可以理解为onchange,而不是$watch
<body ng-app="myApp">
<div ng-controller="myCtrl">
<input type="text" ng-change="myFunc()" ng-model="myValue" />
<p>The input field has changed {{count}} times.</p>
</div>
<script>
angular.module('myApp', [])
.controller('myCtrl', ['$scope', function($scope) {
$scope.count = 0;
$scope.myFunc = function() {
$scope.count++;
};
}]);
</script>
</body>
注意事项
(1)ng-change 指令需要搭配 ng-model 指令使用。
(2)AngularJS ng-change 指令指令不会覆盖原生的 onchange 事件, 如果触发该事件,ng-change 表达式与原生的 onchange 事件都会执行。
(3)ng-change 事件在值的每次改变时触发,它不需要等待一个完成的修改过程,或等待失去焦点的动作。
(4)ng-change 事件只针对输入框值的真实修改,而不是通过 JavaScript 来修改。
4.ng-mouseenter
和ng-mouseleave
指令
ng-mouseenter="oParams.aAddressValidList[item*100+itemOuter*10+itemInner].roomTipsShow=true;"
ng-mouseleave="oParams.aAddressValidList[item*100+itemOuter*10+itemInner].roomTipsShow=false"