I am working on getting up to speed with 1.5 angular components. I have been following todd Motto's videos to get a start on components along with angular's documentation https://docs.angularjs.org/guide/component.
At this point it seems components are taking the place of directives that use controllers, but in our 1.5 code we still would use directives for dom manipulation.
What is the purpose of $element, $attrs inside of a component controller? These seem to be available for manipulation. Here is the link to the plunker off of the docs. I know they are not using $element, but it is the example I am reading. http://plnkr.co/edit/Ycjh1mb2IUuUAK4arUxe?p=preview
But in code like so ...
angular
.module('app', [])
.component('parentComponent', {
transclude: true,
template: `
<div ng-transclude></div>
`,
controller: function () {
this.foo = function () {
return 'Foo from parent!';
};
this.statement = function() {
return "Little comes from this code";
}
}
})
.component('childComponent', {
require: {
parent: '^parentComponent'
},
controller: function () {
this.$onInit = function () {
this.state = this.parent.foo();
this.notice = this.parent.statement();
};
},
template: `
<div>
Component! {{ $ctrl.state }}
More component {{$ctrl.notice}}
</div>
`
})
What would be the use of $element if we are not manipulating the dom?
template
function will have RawDOM
and that is not correct place to do DOM manipulation.. – Alterationcontroller: function($element) { ... }
– Deimos