1

I got my current url with this

   $location.url() which it '/details

This time i want to add some params to it like

'/details/student' 

How can i add '/students' to my current url on click,can any one suggest help please.Thanks.

  <tabset>
<tab heading="student" ng-click = "changeRoutes('student')">
    <h4>STUDENTS</h4>
    <p>Best students..</p>
</tab>
<tab heading="teacher" ng-click = "changeRoutes('teacher')">
    <h4>TEACHERS</h4>
    <p>Best teachers..</p>
</tab>

7
  • Ideally, you should be using either ng-route or angular-ui-router for routing - then use either the href or ui-sref attribute on the element that is clicked to navigate to the new url Commented Jan 25, 2017 at 11:45
  • But i dont have any state declared its a single page html; Commented Jan 25, 2017 at 11:56
  • What do you want to happen when /student is added to the url? Do you want to navigate to that location? Commented Jan 25, 2017 at 11:57
  • No in my html i have 4 tabs in which /student is one. Commented Jan 25, 2017 at 11:58
  • 1
    If you just want to navigate to another url, you can do $window.location.href = '/details/students' - in any case, it would very likely be better to use one of the angular-provided routing options with things that have anything to do with urls Commented Jan 25, 2017 at 12:00

1 Answer 1

1

You need to define router for that like following :-

$stateProvider
//considering route.state is your current state and you need to go on student
  .state(route.state + '.student', {
    url: '/student',
    templateUrl: 'app/examples/student/student.tmpl.html',
    controller: 'StudentController'
  });

Then inside your details controller you need to move to student like following

$scope.baseState.name = $state.current;
$state.go($scope.baseState.name + '.student');

By this way you will load templates for all tabs at the time of loading them.

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

Comments

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.