I am trying to get dynamic data from the json according to $http
results, but it doesn't work for me. I think that the problem is with the callback. I mean that is the code run to json results when my $http
continue to run.
This is my javascript code:
var operation_types = operation_types = [
{nav_id: 1, nav_name: "Validation", nav_src: "validation", nav_href: "validation_list"},
{nav_id: 2, nav_name: "Guests", nav_src: "guests", nav_href: "guests_list"}
];
angular.module("mainApp", ["kendo.directives"])
.controller("HomepageCtrl", function ($scope,$http) {//Homepage
/*receive user properties*/
$http({
url: 'API/v1/User/GetUserInfo',
method: "GET",
headers: { 'Content-Type': 'application/json' }
}).success(function (data, status, headers, config) {
if (data.Code != 1) {
$scope.error = "Please enter valid username and password!";
} else {
console.log(data);
if(data.viewGuest==true&&data.viewValidation==true){
$scope.source =operation_types;
}else if(data.viewGuest==false){
source = operation_types[0];
}else if(data.viewValidation==false){
source = operation_types[1];
}
//window.location.href = "homepage.html";
}
}).error(function (data, status, headers, config) {
$scope.error = "There are problems with connection to server. Status:" + status + " Please, try to connect later.";
$scope.validationClass = "invalid";
});
$scope.source =operation_types;
})
This is the relevant snippet of my html code (with kendo ui):
<kendo-mobile-list-view k-data-source="source">
<div class="product" k-template>
<a href="\#{{dataItem.nav_href}}">
<img src="images/{{dataItem.nav_src}}.jpg" alt="{{dataItem.nav_name}} image" class="pullImage"/>
<h3>{{dataItem.nav_name}}</h3>
</a>
</div>
</kendo-mobile-list-view>
Does somebody know how to do it in angular?