I tried that...
The resource I want to load using $http.get is
http://designfromwithin.com/test-content.json it is just some very basic JSON.
The test physical JSPN file is:
http://designfromwithin.com/assets/templates/gulp_h5bp/package.json This is alo similar JSON, but this one will work, the link above not...
Test pages:
http://designfromwithin.com/ - Does not work
http://designfromwithin.com/test.html - Works
Both use the same code, for both AngularJS is working.
The only change is the JSON, in test 1 the JSON is MODX resource (with content type JSON, custom JSON template)
In test 2 the JSON is a physical file on the site.
JSON template code:
{
"title":"[[*pagetitle]]",
"content":"[[*content]]"
}
These all do not work:
// create the controller and inject Angular's $scope
DESIGNfromWITHIN.controller('mainController', function($scope, $http) {
$http.get('[[~19]]')
.then(function(res){
$scope.message = res.data;
});
});
// create the controller and inject Angular's $scope
DESIGNfromWITHIN.controller('mainController', function($scope, $http) {
$http.get('[[++site_url]][[~19]]')
.then(function(res){
$scope.message = res.data;
});
});
// create the controller and inject Angular's $scope
DESIGNfromWITHIN.controller('mainController', function($scope, $http) {
$http.get('http://designfromwithin.com/test-content.json')
.then(function(res){
$scope.message = res.data;
});
});
But this DOES work... (links to a physical JSON file):
// create the controller and inject Angular's $scope
DESIGNfromWITHIN.controller('mainController', function($scope, $http) {
$http.get('http://designfromwithin.com/assets/templates/gulp_h5bp/package.json')
.then(function(res){
$scope.message = res.data;
});
});
Somehow my JSON MODX resource is not loaded, but I do not know why...
[ed. note: ThaClown last edited this post 9 years, 9 months ago.]