My goal is to create a Single Page Website that relies on a CMS to store and serve JSON data through Ajax requests. I am using ui-router
(previously attempted with ngRoute
) within my ng-app
to handle this data. The challenge I am facing is how to display this dynamic JSON content without using a template or templateUrl
, as it seems to have no impact on the controller.
The issue lies in finding a way to render the retrieved data in the HTML output, as simply using ng-controller
binds the data to a specific controller only. While my console shows successful data reception, I am unable to showcase it in the view.
app.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$urlRouterProvider.otherwise("/");
$stateProvider
.state('state1', {
url: '/state1',
template: '<h1>This Is A State</h1>',
controller: function($scope, $http) {
$scope.pageObj = '';
$scope.pageObj.url = '/angular/demo/';
$scope.pageObj.class = 'page-my';
$scope.pageObj.data = 'Empty';
$http
.get('/angular/demo/')
.then(function(result) {
console.log("Data Received");
console.log(result.data);
$scope.pageObj.data = result.data;
});
//console.log(result.data);
console.log("Hello state");
}
});
});