Using state params in view

207 views
Skip to first unread message

a_gaur

unread,
Mar 6, 2015, 12:31:36 AM3/6/15
to ang...@googlegroups.com
I have been going through many links which states not to use services in angular views :

I stumbled upon a code which used $stateParams directly in an angular view. As the view didn't have any forms and just needed to build a links according to the parameter passed in stateParams it does seemed ok to use it in view. The code is as below

.....
<p>
          {{ 'FORGOT_PASSWORD.CONFIRMATION.CHECK_SPAM' | translate}} <a ui-sref="forgotPassword({email: $stateParams.email})"> {{'FORGOT_PASSWORD.CONFIRMATION.TRY_AGAIN' | translate}} </a>.
</p>
.....

In above I am just creating an anchor tag on the basis of the email passed as the query. Is it ok to directly use stateParams there ? Or should I define a variable on $scope and assign the parameter to that variable and then use the scope variable instead ? It doesn't seem worthwhile.
Reply all
Reply to author
Forward
0 new messages