Well I spent many an hour figuring out just how to accomplish this the
right way. The answer I came up with is:
Use Controller inheritance! Instantiate your server side variables in the
SCOPE object in a parent controller.
Example:
<div ng-controller="ParentControl" ng-init="setServerVars(MY SERVER SIDE
VAR)">
<div ng-controller="childControl"><!-- NEED THE VAR HERE TO MAKE DATA
CALL --->
</div>
</div>
I hope someone finds this useful!
Brad Newman
On Thursday, January 23, 2014 1:54:14 PM UTC-5, Bradley Newman wrote:
>
> Hello,
>
> I am trying to do something that would seem fairly simple.
>
> In my controller I have a service that I need to pass a server side
> parameter into:
>
> var data = dataService.query({*serverSideVar*:*scope.serverSideVar*},
> function() {
> });//Get Data
>
> I need to know how to instantiate the server side variable so that it
> available at the time of the data call.
>
> I have tried using ng-init on the my controller tag
> <div ng-controller="myController" ng-init="instantiateValueInScope('My
> Value')">
>
> In my controller used this to try to pass the value:
>
> scope.instantiateValueInScope = function (myValue) {
> // This is used on controller load to
> // instantiate server side vars
> scope.*serverSideVar* = myValue;
> };
>
> My variable is not carrying over before the data call happens. How can I
> get my server side value into my service call before it fires?
>
> Thanks in advance!
>
> Brad Newman
>
--
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/groups/opt_out.