i'm asking for your help. I'm an AngularJS begginer and components bindings looks like esotherical for me. I don't really understand why my variables a sets to undefined.
Could you help me please ?
Here is my HTML :
<div ng-controller="mapController as map" style="text-align:center;">
<div>{{map.lastClickedCountry}}</div>
<risk-map lastClickedCountry="map.lastClickedCountry"
countriesUnits="map.countriesUnits">
</risk-map>
</div>
My Component JS :
angular.module('riskApp').component("riskMap", {
bindings: {
lastClickedCountry: '=',
countriesUnits: '='
},
templateUrl: 'template/risk.html',
controller: function ($scope) {
this.$onInit = function () {
console.log("onInit")
console.log(this);
console.log($scope);
};
this.$onChanges = function () {
console.log("onChange")
console.log(this);
console.log($scope);
};
this.setArrivant = function (pays, nombreArrivant) {
this.countriesUnits[pays].arrivant = nombreArrivant
}
this.setStationnaire = function (pays, nombreStationnaire) {
this.countriesUnits[pays].stationnaire = nombreStationnaire
}
this.getArrivant = function (pays) {
return this.countriesUnits[pays].arrivant
}
this.getStationnaire = function (pays) {
return this.countriesUnits[pays].stationnaire
}
this.click = function (country) {
console.log("Dernier pays : " + this.lastClickedCountry)
console.log("Pays click : " + country)
console.log(this)
this.lastClickedCountry = country;
}
}
})
My Controller JS:
angular.module('riskApp').controller('mapController', function
CountCtrl($scope) {
this.lastClickedCountry = "test";
this.countriesUnits = {}
})
this.countriesUnits = {);