0

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

2 Answers 2

2
function MyCtrl($scope, $location) {
    $scope.create = function() {
        // do something
        $location.path('/show');
    }
}

See $location API

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

Comments

0

You can use $location, the built in service to do that.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.