0

我想在 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 类中。我知道你是专家。

4

0 回答 0