20

rather than do this

<input type="checkbox" name="AltSchedule" ng-show="someVar" />

i want to be able to do this

@Html.CheckBoxFor(model => model.AltSchedule, new  {ng-show="someVar" })

but i can't seem to find an answer on who to accomplish using the html helpers with angular tags. Is there way to add angular tags to the html attributes parameter for an html helper?

2 Answers 2

39

Underscores in the htmlAttributes parameter are converted to hyphens when the control is rendered:

@Html.CheckBoxFor(model => model.AltSchedule, new  {ng_show="someVar" })
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, this helped me 4 years after you answered.
4

You can use the overload that takes a dictionary:

@Html.CheckBoxFor(model => model.AltSchedule, new Dictionary<string, object>() { { "ng-show", "someVar" } })

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.