I have an ng-include
html element, and want to pass some data from outside to the controller.
The main controller
fetches
json
data
from a http webservice
, and extracts the data into the scoped variable climadata
.
The following is pseudocode
, but you get the idea:
function mainController($scope, $http) {
$http.get().then(
$scope.climadata = response.clima;
);
}
<div ng-controller="mainController">
<div ng-include="'clima.html'" ng-controller="climaController" onload="climamodel = climadata"></div>
</div>
This works fine, BUT the climadata never reaches the climaController
. Checked as follows:
function climateController($scope) {
console.log($scope.climamodel); //prints "undefinied"
};
The climamodel is always undefined in console, but why?