0

Currently i am upgrading an Angularjs 1.6 app into Angular 7. As part of this migration i have to navigate to a state defined in Angularjs from Angular template. How can i achieve this?

I have tried angular-hybrid router approach, but it didn't help.

This is the state defined under recipes module in Angularjs

$stateProvider.state('recipes', { url: '/recipes', component: 'recipes', onEnter: ['$state', 'authService', ($state, authService) => { if(!authService.isLoggedIn()){ $state.go('login') } }] })

And i want to navigate to above state from Angular 7 template as shown below using angular-hybrid-router

  <a class="list-group-item"
     style="cursor: pointer;"
     ui-sref="recipes"
     *ngFor="let recipe of recipes; let i = index;">
    {{recipe.name}}
  </a>
</ul>

Expected is to navigate to /recipes url. But it doesn't and even doesn't thrown any error.

1
  • Not enough information to answer. You're using ui-router in the angular-js example, but I see no routing logic in the second example, just an anchor tag with an ng-for directive. Commented Jun 4, 2019 at 19:11

1 Answer 1

0

I am unfamiliar with angular-hybrid; though from a cursory glance, it is probable the routing module registering the state was not imported in a module that is chained to the app's root module. uiSref directive can only resolve a registered state, IIRC ui-sref wont give an error if your ui-sref value is 'invalid'(read: unregistered).

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.