将angular 1.x指令升级为angular 2

时间:2016-08-30 02:25:30

标签: javascript angularjs angular

我正在尝试将某些指令升级为角度2,但我无法找到每个属性如何转换为角度2.假设我想升级以下,如何才能完成?请让我知道,或引导我到一个我能找到它的地方。 THX

 angular.module('grid.provider', [])
    .provider('gridFactory', function() {
      'use strict';
       this.defaults = {};
      this.factory = function (options) {
        return new Grid(options); //from included js
      };

    angular.module('grid.init', ['grid.provider'])
      .controller('gridCtrl', ['$scope', '$attrs', 'gridFactory',
      function ($scope, $attrs, gridFactory) {
       var options = angular.extend({}, $scope.$eval($attrs.gridInit));
        var grid= gridFactory.create(options);

        grid.on('getAll', function (gridEventName) {
          var args = Array.prototype.slice.call(arguments);
          args.shift();
          var event = $scope.$broadcast.apply($scope, ['grid::' + gridEventName, grid].concat(args));
          if ({
            'success':1, 'error':1
          }[gridEventName]) {
            $scope.$apply();
          }

        });


      }])
      .directive('gridInit', [function() {
        return {
          scope: true,
          controller: 'gridCtrl'
        };
      }]);


    angular.module('grid.saveBtn', ['grid.init'])
    .directive('saveBtn', [function() {
      return {
        'restrict': 'E',
        'scope': false,
        'require': '^gridInit',
         'link': function(scope, element, attrs) {
                //script to save
        }

      };
    }]);

0 个答案:

没有答案