0

I need that code will be called in controller ChatController, not in global application:

.config(function($routeProvider){
            $routeProvider.when("/chat/dialog/:id",
                {
                    templateUrl: "/template/chat/active_dialog.html",
                    controller: "ChatController"
                }
            );
        })

How I can do it?

I tried (template is not loaded in div):

Angular JS:

$scope.selectDialog = function (id, event){
   $scope.template = '/template/chat/active_dialog.html';
});

HTML:

<div ng-include src="{{template}}"></div>
5
  • Seems similar to this stackoverflow.com/questions/16384134/… .Is that what you are looking for? Commented Apr 8, 2015 at 11:46
  • could you be a little more specific? what do you mean with "not in global application"? Do you want to define the Route in the controller (not possible)? Commented Apr 8, 2015 at 11:46
  • Yes, I want to define route in Controller, is it not possible? How I can load template then? Commented Apr 8, 2015 at 11:48
  • 1
    the $routeProvider is just accesable in the config phase of the application, that means you cant use the $routeProvider in controllers. The template is loadet automaticly from the url you set in templateUrl Commented Apr 8, 2015 at 11:49
  • you could create a separate module for this? I imagine you would need to create a third module for anything shared between modules. Commented Apr 8, 2015 at 12:02

1 Answer 1

1

I agree with @Nano,all the providers that are used angular are injected and used in .config,you directly cannot use it in your controller.

Sign up to request clarification or add additional context in comments.

1 Comment

Are you calling this function $scope.selectDialog()?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.