javascript - Covert pure angular to ecma6 plus angular -
i want build dynamic controllers in eccma script code.i'll show example angular code.but couldn't understand how implement in 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;
=========================================================================
i want add controllers following eccmascript 6 code.if 1 can appreciate , great help.
angular code.
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 "); } })
please me add above eccma6 class.i know expert.
Comments
Post a Comment