D
D
Denis Denis2015-12-29 08:29:07
Angular
Denis Denis, 2015-12-29 08:29:07

How to redirect to main Angular?

Hello!
The link
angular.js-example/#
shows a list of tasks
The link
angular.js-example/#/tasks/12
shows a detailed description of the task
To return to the main one made a directive

taskApp.directive('backButton', function ($location) {
    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
            element.on('click', function () {
                $location.url('/')
            });
        }
    };
});

In theory, it should redirect to the main one.
Why does not it work?
You can, of course, write, history.back()but then those who came through angular.js-example/#/tasks/12 will leave the site
Thank you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nicholas, 2015-12-29
@golovewkin

1. Why are you posting the event via the DOM?
Hang through ng-click.
2. Try $location.path('/');
it 3. I understand that you are doing this for learning, but it's better to start using angular-ui-router right away , because There is a lot of much needed functionality there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question