Hi Masoud,
No need to invoke viewFile manually.  The angular digest loop will take
care of it for you.  You just need to set your conditions in the controller
to switch template files based off some value found in the service.

Check out this plunk
http://plnkr.co/edit/LXOihD

Gordon


On Thu, Jun 19, 2014 at 10:18 AM, Masoud gheisari <[email protected]>
wrote:

> Very good respond, i have taken out all of that and created a service to
> do Authentication. now my question still remains. here is part of my code:
>
> <div ng-controller="defaultCtrl">
>         <ng-include src="viewFile()"></ng-include>
>     </div>
>
> angular.module('app', [])
>   .controller('mainCtrl', function() {
>
>     $scope.viewFile = function(){
>        if( condition A)
>              retrun viewA;
>        else
>            return viewB;
>     }
>
>   });
>
> .service('AuthService', function() {
>    $http({
>        get ....
>         .success: function (data){
>           // INVOKE viewFile() FROM CONTROLLER ABOVE?????
>         }
>     });
> });
>
>
> i want to know if there is a way that i can define viewFile in controller
> and then anfter using a service, invoke the function to do the updates. if
> not, would i be able to create viewFile() function in a service and still
> bind it to ng-inclue in my html file?
>
>
>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "AngularJS" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/angular/ZfPe9-NFmLU/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>

-- 
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.

Reply via email to