Created
December 1, 2015 09:04
-
-
Save tuchk4/6c25e0fc25cb5eb5d31d to your computer and use it in GitHub Desktop.
Directive - Valentjs vs AngularJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('example').directive('helloWorld', function() { | |
return { | |
restrict: 'E', | |
template: '<div> {{ name }} </div>', | |
link: function(scope, element) { | |
// scope.name = 1; | |
element.addClass('orange')l | |
}, | |
controller: ['$scope', funtion($scope) { | |
$scope.name = 1; | |
}] | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorldController { | |
name = 1; | |
constructor() { | |
} | |
link(element) { | |
element.addClass('orange'); | |
} | |
static render() { | |
return '<div> {{ name }} </div>'; | |
} | |
} | |
valent.component('hello-world', HelloWorldController); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorldController { | |
name = 1; | |
constructor() { | |
} | |
link(element) { | |
element.addClass('orange'); | |
} | |
} | |
valent.component('hello-world', HelloWorldController, { | |
template: '<div> {{ name }} </div>', | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment