Or you can use ui-router <https://github.com/angular-ui/ui-router> with 
which you define states, so you have "showState" among others (and you can 
nest them too) which has a template + controller that you need.

var myApp = angular.module("MyApp", ["ui.router"])
    .config(function($urlRouterProvider, $stateProvider) {
        // ...
        $stateProvider.state("showState", {
            url: "/show",
            controller: "ShowCtrl",
            templateUrl: "/templates/show.tpl.html"
        });
        // ...
    });

Then you can:

function MyCtrl($scope, $state) {
    $scope.create = function() {
        // do something
        // ...
        // redirect to `#/show`, another view and controller will be used
        $state.go("showState");
    }
}

Hope that was helpful.


On Wednesday, May 23, 2012 7:41:00 AM UTC+3, Freewind wrote:
>
> For example, there is a button "Create" in my page, and it has ng-click 
> attribute:
>
>     <button ng-click="create()">Create</button>
>
> And in the `create()` function, I want to do something, then redirect to 
> another route `#/show`, which is a client site route defined in angularjs:
>
>     function MyCtrl($scope) {
>         $scope.create = function() {
>              // do something
>              // how to redirect to `#/show`, another view and controller 
> will be used
>         }
>     }
>
>
>

-- 
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 angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to