In the below code and after using bind(this), I was able to use this.name in configureItemScope.
However when I call updatename() the value of itemScope.item does not get updated. it seems it's not binding to this.name?
module.controller('ListController', function () {
this.name = "initial";
this.delegate = {
configureItemScope: function (index, itemScope) {
itemScope.item = this.name;
}.bind(this)};
this.updatename = function(){ this.name = "changed"; }.bind(this)
});
When you click the button, the values to do not change: https://codepen.io/scatman007/pen/PywGor
<ons-page ng-controller="ListController as list">
<ons-button ng-click="list.change()">click to change</ons-button>
<ons-list>
<ons-list-item ons-lazy-repeat="list.delegate">{{ item }}</ons-list-item>
</ons-list>
</ons-page>
JS
ons.bootstrap()
.controller('ListController', function() {
this.delegate = {
configureItemScope: function(index, itemScope) {itemScope.item = "OLD";},
countItems: function() {return 0;}
};
this.change = function()
{
this.delegate.configureItemScope= function(index, itemScope) {
itemScope.item = "NEW";
}
this.delegate.countItems= function() { return 1000;}
}.bind(this);
});