Answer the question
In order to leave comments, you need to log in
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('/')
});
}
};
});
history.back()
but then those who came through angular.js-example/#/tasks/12 will leave the site Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question