隐藏纯角度到ecma6加上角度

时间:2015-09-30 08:56:47

标签: javascript angularjs-directive angularjs-scope ecmascript-6 angular-controller

我想在eccma脚本代码中构建动态控制器。我将通过角度代码展示一个例子。但是我无法理解如何在eccma6中实现它。

let module = 'app.core.checka';
    class WindowViewer{
        constructor() {

    this.restrict = 'E';
            this.template = ` < Button ng - click = "sendMsg()" > 85855 < /Button><div ng-model="ngModel" kendo-window="windowId" k-title="'AJAX content'"
            k - width = "'90%'" k - height = "'90%'" k - visible = "false" k - draggable = "false"
            k - max - height = "'100%'" k - max - width = "'100%'" k - position = "{top: '10px', bottom: '100px', left: '5%', right: '5%'}"
            k - position - left = "'5%'"
            k - pinned = "true"  k - actions = '[ "Minimize", "Maximize" ,"Close", "Refresh"]'
            k - content = "{url: '{{ content }}' }"
            k - on - open = "win2visible = true" k - on - close = "win2visible = false" > < /div>`;

            this.controller = '@';
            this.name = 'controllerName';
            this.scope = {
            ngModel: '=',
                    content: '=',
                    windowId: '=',
                    minimize: '=',
            }

    }


    link(scope, elm, attrs, ctrl) {
    console.log(scope);
            if (angular.isDefined(scope.ratio)) {
                let ratio = scope.ratio.split(':');
                scope.offset = ratio[0];
                scope.inputWidth = ratio[1];
            }

    }

    static directiveFactory() {
            WindowViewer.instance = new WindowViewer();
            return WindowViewer.instance;
    }

    static callMe(){
      alert(884855);
    }
 }

   angular.module(module, [])
    .directive('windowViewer', WindowViewer.directiveFactory);


    export default module;

=============================================== ==========================

我想将控制器添加到以下eccmascript 6代码中。如果任何人能做到的话会很感激并且会给你很大的帮助。
这是角度代码。

  var app = angular.module('myApp',[]).
  directive('communicator', function(){
       return {
       restrict : 'E',
       scope:{},
       template:"<input type='text' ng-model='message'/><input type='button'         
       value='Send Message' ng-click='sendMsg()'><br/>",
       controller : "@",
       name:"controllerName"    
    }   
     }).
     controller("PhoneCtrl",function($scope){
     $scope.sendMsg = function(){
     alert( $scope.message + " : sending message via Phone Ctrl");
   }
   }).
    controller("LandlineCtrl",function($scope){
    $scope.sendMsg = function(){
    alert( $scope.message + " : sending message via Land Line Ctrl ");
 }
 })

请帮我把它添加到上面的eccma6课程中。我知道你是专家。

0 个答案:

没有答案