Last active
November 11, 2015 22:20
-
-
Save creaux/1b416a3d00f88cfcb275 to your computer and use it in GitHub Desktop.
Angular Component
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 js foo module declaration | |
// which is later instantiated in html | |
var foo = angular.module('foo', []); | |
// Let's declare new angular hello component | |
foo.component('hello', { | |
// Use template | |
template: '<h3> {{ hello.message }} </h3>', | |
// Define controller | |
controller: function() { | |
this.message = 'Hello I\'m component.'; | |
} | |
}); | |
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
var foo = angular.module('foo', []); | |
foo.component('hello', { | |
template: ` | |
<header ng-transclude="headerSection"></header> | |
<h3> {{ hello.message }} </h3> | |
<div ng-translude="contentSection"></div>`, | |
// New bidings attribute | |
bindings: { | |
hello: '=' | |
}, | |
// It's true by default | |
// You can declare all translusions using object | |
// with mappings just like bindings (scope in directive) | |
// then you have to just add this transclusion into template | |
// using ng-transclude="contentHeader" for example | |
translude: { | |
header: ?headerSection, | |
content: contentSection | |
}, | |
// It's true by default | |
isolate: true, | |
controller: function() { | |
this.message = 'Hello I\'m component.'; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment