angularjs - How to convert this code from angular1 to angular2 -


there, want use ng-class="{active: isopen()}" in angular 2, don't know ,how convert code angular1 angular2, 1 me? thank much. code there:http://www.theme-guys.com/materialism/angular/#/apps/todo

app.directive('menutoggle', ['$location', function($location) {    return {      restrict: 'a',      transclude: true,      replace: true,      scope: {        name: '@',        icon: '@'      },      templateurl: 'assets/tpl/directives/menu-toggle.html',      link: function(scope, element, attrs) {        icon = attrs.icon;        if ( icon ) {          element.children().first().prepend('<i class="' + icon + '"></i>&nbsp;');        }          element.children().first().on('click', function(e) {          e.preventdefault();          link = angular.element(e.currenttarget);            if( link.hasclass('active') ) {            link.removeclass('active');          } else {            link.addclass('active');          }        });          element.find('a').ripples();          scope.isopen = function() {          folder = '/' + $location.path().split('/')[1];          return folder == attrs.path;        };      }    };  }]);
   <li menu-link="" href="#/" class="ng-isolate-scope">            <a ng-transclude="" ng-class="{active: isopen()}" href="#/ui-elements/cards" class=""><span class="ng-scope">cards</span><div class="ripple-wrapper"></div></a>          </li>

"how convert code angular1 angular2?"

3 easy steps:

1- go page:

https://angular.io/docs/ts/latest/guide/upgrade.html

2- try yourself.

3- if have specific questions (questions, not free work requests) go http://stackoverflow.com , ask them there.

i hope helps.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -