I am trying to load a local json file and get the data in to a $scope variable.
myApp.controller('myController', ['$scope', '$http', function ($scope, $http) {
$scope.menu = function () {
$http.get('file.json')
.then(function (data) {
$scope.menu=data.data.menu;
});
};
Also I tried return data.data.menu
. But not menu is not updating.
Tried caling this on page load.
$scope.menu();
In html:
<body ng-app="myApp">
<div ng-controller="myController">
<ul class="nav navbar-nav" ng-repeat="item in menu">
// other stuffs
What is wrong here.
I Simply put the below code directly in the controller, but still not working.
$http.get('file.json')
.then(function (data) {
$scope.menu=data.data.menu;
});