Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am sending a variable to a PHP file as a parameter on a route with AngularJS. The PHP file then returns an array of objects in a Smarty variable that I would like to use in a normal ng-repeat in the new view that is loaded. How can this be accomplished? I have looked into http, resolve, promises, resolve+RequireJS lazy loading. I can not figure out the best way to accomplish this, let alone a way that functions at all. Heck at this point I'd even use a hack if it functioned.

The problem is that in the myProjects controller, if I define the Smarty variable returned from my PHP file, that data will not be available until AFTER the route with the userId parameter has been called, so it throws an undefined error and kills the entire script.

Any suggestions very much appreciated!

\$routeProvider
        // route for a clients projects
        .when('/clientprojects/:userId', {
            templateUrl : function(params){ return '/dealer-admin/clients?tpl=true&data='+params.userId; },
            controller  : 'myProjects'
        })
share|improve this question
    
I dont understand. Do you have a problem fetching the data or displaying the data? –  Ankit Ladhania 13 hours ago
    
I can send the parameter like I do above, then fetch data based on the param, then return and display it with a smarty variable in the new view. The problem is that I can not use this smarty variable in the myProjects controller after it has been fetched, so the fetched data is basically worthless to me. If I can't use that Smarty variable in the myProjects controller then I can't use it in ng-repeat, I can't filter it, I essentially can't manipulate it in the view in any way. I need to figure out how to return it all the way back to my angular app, not just echo a smarty variable in the view –  Patrick Lawler 12 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.