# How to change a view if state is equal to

**URL:** <https://discuss.emberjs.com/t/how-to-change-a-view-if-state-is-equal-to/11160>\
**Category:** Uncategorized\
**Created:** [July 14, 2016, 5:27pm UTC](https://discuss.emberjs.com/t/how-to-change-a-view-if-state-is-equal-to/11160 "2016-07-14T17:27:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![BobrImperator](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/bobrimperator/32/12449_2.png) [@BobrImperator](https://discuss.emberjs.com/u/BobrImperator)\
**Post date:** [July 14, 2016, 5:27pm UTC](https://discuss.emberjs.com/t/how-to-change-a-view-if-state-is-equal-to/11160/1 "2016-07-14T17:27:07Z")

</div>

Hello, there I’ve recently started learning Ember.js , and I’m writing a game “hangman”. I’m having trouble with Ember.js’s templates, I have a “state” defined inside component, and I want to switch between templates if state = won , so it won’t be so messy , right now all game is written in 2 files, a component and it’s template. Currently I’m attempting to refactor it.

I’d like to have different view for state = won || lost || provideWord . Tried to work it out with routes , but didn’t manage to either.

---

<div class="post-metadata">

**Author:** ![acorncom](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/acorncom/32/12198_2.png) [@acorncom](https://discuss.emberjs.com/u/acorncom)\
**Post date:** [July 15, 2016, 4:42am UTC](https://discuss.emberjs.com/t/how-to-change-a-view-if-state-is-equal-to/11160/2 "2016-07-15T04:42:13Z")

</div>

Do an if in your template and then display two different components depending on which path gets taken. That way you can skip routes.

This used to be done with partials, but those are heading toward being deprecated …

---

<div class="post-metadata">

**Author:** ![BobrImperator](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/bobrimperator/32/12449_2.png) [@BobrImperator](https://discuss.emberjs.com/u/BobrImperator)\
**Post date:** [July 21, 2016, 12:07pm UTC](https://discuss.emberjs.com/t/how-to-change-a-view-if-state-is-equal-to/11160/3 "2016-07-21T12:07:55Z")

</div>

I am sorry for so late reply! It’s that I am a minor programmer, and I am also working during vacation. Thank you for your advice, it worked! I should have done that before tho.

But why is it going to get deprecated, is it inefficient ?

---

<div class="post-metadata">

**Author:** ![acorncom](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/acorncom/32/12198_2.png) [@acorncom](https://discuss.emberjs.com/u/acorncom)\
**Post date:** [July 23, 2016, 5:39pm UTC](https://discuss.emberjs.com/t/how-to-change-a-view-if-state-is-equal-to/11160/4 "2016-07-23T17:39:21Z")

</div>

It will get deprecated because partials “leak context”. Meaning your partial works differently depending on what other template it gets called from. Unlike a component where the inputs are all defined, partials get messier. Ember is steadily moving toward APIs that encourage explicit inputs as it makes life better for all of us (framework authors included) 😉

---

<div class="post-metadata">

**Author:** ![BobrImperator](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/bobrimperator/32/12449_2.png) [@BobrImperator](https://discuss.emberjs.com/u/BobrImperator)\
**Post date:** [July 23, 2016, 7:21pm UTC](https://discuss.emberjs.com/t/how-to-change-a-view-if-state-is-equal-to/11160/5 "2016-07-23T19:21:40Z")

</div>

That gives me an overall insight in direction Ember is taking. But still , I think I don’t really understand what that means, except that it will be more friendly to Developers.

My code is depending on ‘state’ defined in service, and components are changing it’s state via actions, it also gives me a notification in browser’s console “DEPRECATION: You modified ShouldDisplay((eq playGame.state “provideWord”)) twice in a single render. This was unreliable in Ember 1.x and will be removed in Ember 3.0 [deprecation id: ember-views.render-double-modify]”

Is that what you mean?
