发表于: 2017-06-13 23:47:33

1 1029


今天完成的事情:

1,为后台表单添加验证。

2,修改css样式。

3,学习angular自定义指令。

angular.module('myApp', [])
   .directive('myDirective', function() {
       return {
           restrict: String, // 默认为A,指令在DOM中可以何种形式被声明,元素E、属性A、类名C、注释M
           priority: Number, // 优先级
           terminal: Boolean, // 默认false,设为true,停止运行当前元素上比本指令优先级低的指令
           template: String or Template Function: function(tElement, tAttrs) (...},
templateUrl: String, // 模板使用Ajax异步加载
           replace: Boolean or String, // 默认为false,设为true,引用的模板会替换原来的
           scope: Boolean or Object,
transclude: Boolean,
controller: String orfunction(scope, element, attrs, transclude, otherInjectables) { ... },
controllerAs: String,
require: String,
link: function(scope, iElement, iAttrs) { ... },
compile: // 返回一个对象或连接函数,如下所示:
           function(tElement, tAttrs, transclude) {
               return {
                   pre: function(scope, iElement, iAttrs, controller) { ... },
post: function(scope, iElement, iAttrs, controller) { ... }
               }
               // 或者
               return function postLink(...) { ... }
           }
   };
});

4,angular提供了许多默认过滤器,我们也可以自定义:

//注入过滤器
indexApp.filter('status', function() {
   return function(text) {
       var a;
       switch(text)
       {
           case 1:
               a="草稿";
               break;
           case 2:
               a = "上线";
               break;
           default:
               a = "状态未知";
       }
       return a;
   }
});




明天计划的事情:

完成分页。


遇到的问题:

暂无。


收获:

文本两端对齐时,可用text-align:justify属性,但兼容性不太好,无效时可用text-align-last:justify。


返回列表 返回列表
评论

    分享到