I tried to implement for first time the controller as syntax and I face a problem where my function doesn't change the controller variable which I pass from the template. Instead it understands the parameter as a local variable. This wouldn't happen if I use $scope.
Here's my controller.
angular
.module('app')
.controller('baseCtrl', baseCtrl);
function baseCtrl() {
base = this;
base.myVar = 'string_1';
base.myFunction = myFunction;
function myFunction(value) {
value = 'string_2"';
}
}
Here's my template.
<div ng-controller="baseCtrl as base">
<button ng-click="base.myFunction(base.myVar)">Button</button>
</div>
After click base.myVar should change from "string_1" to "string_2" but this doesn't happen.
Does somebody know how I could figure it out ?