Hi. I might not explained myself properly.
I have a state on my app, and that state has one of four possible template
HTMLs (i have an integer param on database). All htmls have similar
behaviour, but one of them has to invoke a function in order to
automaticaly fill in a model variable. How can i invoke a function on this
templatehtml? I tried ng-init, but did not worked as expected.
By the way, i would like to have an opinion of this implementation:
---
angular.module(...).config(
...
var initInjector = angular.injector(['ng']);
var $http = initInjector.get('$http');
var config = {url:"URL_TO_RESOURCE", method: "GET"};
var callbackSuccess = function(data) {
var template = null;
switch(data.param) {
case 1:
template = "templates/page1.html";
break;
case 2:
template = "templates/page2.html";
break;
case 3:
template = "templates/page3.html";
break;
default:
template = "templates/page4.html";
break;
}
$stateProvider.state("XPTO", {
url: "/XPTO",
views: {
"content": {
templateUrl: template,
controller: "XPTOCtrl"
}
}
});
};
var callbackError = ...;
$http(config).success(callbackSuccess).error(callbackError);
...
);
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.