here is my code.
.state("dynamic", {
url: "/:name",
controller : 'AppHomeCtrl',
templateUrl: function (params){
var myURL = params.name + '.html';
var validPage = true;
$.ajax({
url: myURL,
async: false })
.done(function(data) {
console.log(data);
if (data.toLowerCase().indexOf("doctype") >= 0) {
validPage = false;
}
})
if (!validPage) {
return 'error.html';
} else {
return params.name + '.html';
}
},
Is this possible to rewrite a state of a route (using angular-ui-routes) to get a page based on if the page gotten has a doctype or not?
the code above works perfectly. but how can I replace $.ajax with $http I must be missing something...
$http.get(url).success(function(data) {
if (data.toLowerCase().indexOf("doctype") >= 0) {
validPage = false;
}
});
do I need to load $http somewhere higher up? etc.