john john - 3 months ago 46
HTML Question

Anchor tag not working with Angular UI-Router

I am new to AngularJS. I want to pass a parameter through anchor tags in the following

$stateProvider
code of AngularJS, but it is not working. What is the proper way to send a parameter via anchor link in
ui-sref


<a ui-sref="Type/valid">Valid Email</a>
<a ui-sref="Type/invalid">Invalid Email</a>

app.config(function($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise('Type/valid');
$stateProvider.state("Type", {
url:"/Type/:type",
templateUrl: "valid.php"
});
});

Answer

With ui-sref you can specify arguments like that

<a ui-sref="Type({ type: 'valid' })">Valid Email</a>
<a ui-sref="Type({ type: 'invalid' })">Invalid Email</a>