### controllerAs的使用

  1. 正常设置scope对象的参数,bindToController参数值改为true
    'use strict';
    angular.module('nodeInAction')
    .directive('countCard', function () {
    return {
    restrict: 'E',
    scope: {
    icon: '@',
    title: '@',
    count: '@',
    unit: '@',
    colorStyle: '@'
    },
    controllerAs: 'vm',
    bindToController: true,
    templateUrl: 'app/components/countCard/countCard.html',
    controller: function () {
    var vm = this;
    console.log(vm);
    }
    };
    });
posted @ 2017-08-23 11:37  天空中翱翔的鱼  阅读(191)  评论(0编辑  收藏  举报