I'm trying to use AngularJs 1.5 components but everytime I declare bindings I keep getting this error:
Expression 'undefined' in attribute 'message' used with directive 'homeComp' is non-assignable!
I'm trying a simple component, just to learn it, this is the code:
var component = {
bindings: {
message: '='
},
controllerAs: 'vm',
controller: function MainController() {
this.message = 'Welcome to my component';
function debug() {
this.message = 'This message changed';
}
this.debug = debug;
},
template: [
'Message: {{ vm.message }}<br />',
'<button ng-click="vm.debug()">Change message</button>'
].join(``)
};
You can see the error here: http://plnkr.co/edit/uutk5kxOVpa5eLfjoa8U?p=preview
What is wrong with the code? Or what is causing this error? If I remove the bindings, the error doesn't appear and I can change the message.