0
I am using Angularjs, in creating a Component I need to access the bindings in my controller.
In html I’m calling Component so:
<component type='tipo' urlid='meuid'></component>
I’m using the second syntax for bindigs:
bindings: {
type: '@',
urlid: '@'
}
And on the controller I’m using:
function meuController() {
var vm = this;
console.log(vm);
console.log(vm.type);
console.log(vm.urlid);
}
I’m having this comeback:
As it is possible to see in the image the attributes then in the controller(vm) but when I access them I get the return undefined
.
How do I access these attributes?
Inside your component’s html, try using $Ctrl.addName
– Paulo Gustavo
Using $Ctrl.html nameAtributo I am able to access the data. The problem is that I need to use them in my Component controller.
– Mateus Koppe
In my code I make a reference to the scope like this: "var self = this;", and in the controller, to access the attributes, I use self.attributeName
– Paulo Gustavo
Ata, I messed up here, sorry, already tried to access using vm["type"] ?
– Paulo Gustavo
Using
vm['type']
I have the same returnundefined
.– Mateus Koppe