发表于: 2017-06-10 15:35:13

1 745


 

今天完成的事情:(一定要写非常细致的内容,比如说学会了盒子模型,了解了Margin) 

复盘项目萝卜多方案评审不通过,重写前台方案,修改后台方案

我负责修改后台方案

搭建后台管理系统路由

明天计划的事情:(一定要写非常细致的内容) 

把后台方案完善一下,保证后天评审。

遇到的问题:(遇到什么困难,怎么解决的) 

使用了 controllerAs 有什么区别呢? 

在 AngularJS 的文档中是这样说的:

one binds methods and properties directly onto the controller using this: ng-controller=”SettingsController1 as settings”

one injects $scope into the controller: ng-controller=”SettingsController2”

使用 controllerAs 时, 可以将 Controller 定义成 Javascript 的原型类, 在 HTML 视图中直接绑定原型类的属性和方法。

这样做的优点是:

可以使用 Javascript 的原型类, 我们可以使用更加高级的 ES6 或者 TypeScript 来编写 Controller ;

避开了所谓的 child scope 原型继承带来的一些问题

使用 controllerAs 将直接绑定 Controller 的属性和方法, 而不使用 controllerAs

将绑定到为 Controller 注入的 $scope 参数

简单的说,就是使用了 controllerAs:vm  指令之后, AngularJS 会将 controller 的实例作为对应的 scope 的一个属性,

 这个属性的名称就是 vm , $scope.vm 就是 controller 的实例。

收获:(通过今天的学习,学到了什么知识)

搭建后台管理系统环境路由

/**
*
配置项目的路由,使之可以在几个页面中做单页面跳转(配置路由)
*
* @param $stateProvider
* @param $urlRouterProvider
* @param $ocLazyLoadProvider
* @param $locationProvider
*/

function projectRouteConfig($stateProvider$urlRouterProvider$ocLazyLoadProvider$locationProvider) {
   var _lazyLoad = function (loaded) {
       return function ($ocLazyLoad) {
           return $ocLazyLoad.load(loaded{
               serie: true
           });
       }
   };
   //按需加载
   $ocLazyLoadProvider.config({
       debug: false,
       //debug: $ocLazyLoad returns a promise that will be rejected when there is an error but if you set debug to true, $ocLazyLoad will also log all errors to the console.

       //debug$ ocLazyLoad 返回一个 promise对象,当有错误时将拒绝,但是如果将debug设置为true$ ocLazyLoad也会将所有错误记录到控制台。
       events: true
       //events: $ocLazyLoad can broadcast an event when you load a module, a component or a file (js/css/template).
       // It is disabled by default, set events to true to activate it. The events are  ocLazyLoad.moduleLoaded,
       // ocLazyLoad.moduleReloaded, ocLazyLoad.componentLoaded, ocLazyLoad.fileLoaded.

       //事件:$ ocLazyLoad可以在加载模块,组件或文件(js / css / template)时广播事件。默认情况下禁用,将事件设置为true以将其激活。事件是
       // ocLazyLoad.moduleLoaded, ocLazyLoad.moduleReloaded, ocLazyLoad.componentLoaded, ocLazyLoad.fileLoaded.


       // modules: predefine the configuration of your modules for a later use. You will have to specify the name of the module here so that we can find the reference later.
       // 模块:预先定义模块的配置以备以后使用。您必须在此处指定模块的名称,以便稍后找到该参考。
   });

   //更改url格式配置为html5,去掉#
   // $locationProvider.html5Mode(true);

   $urlRouterProvider.otherwise('/dashboard');
   //在路径没有匹配的路由的时候,跳转(重定向)到一个默认的路径
   //用来配置非 $state 的额外的路由

//$state.go 函数可以将状态位置强行切换


返回列表 返回列表
评论

    分享到