1

I am doing a SPA. I am using ngResources and I have a really simple form.

User can compile it and after he submit the form should appear a new form with only a message that says something like this: "Thank you to use our form ..."

I would like to avoid something like

$("#myForm").hide();
$("#myMessage").show();

because I think it is not the correct way to manage views in angular. I think I should use routing... Honestly I don't know...

In this moment I am using ngSwitch. I think ngSwitch is worst than using jQuery because ngSwitch change the scope of the view. So my model change from

<input data-ng-model="MyProp" ... />

to

<input data-ng-model="$parent.MyProp" ... />

I don't want to fill my form with $parent. I think it does not make sense in this context. Which is the correct way to change view after in angularJs?

Thank you

Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
Simone
  • 2,304
  • 6
  • 30
  • 79

1 Answers1

1

You could easily managed that in your controller, You should declare myProp in some object.

$scope.options = {};

then place myProp inside options variable

<input data-ng-model="options.MyProp" ... />
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
  • mm... I think in this way I should access myProp in this way: `$parent.options.MyProp` because my scope is ngSwitch... no? – Simone Apr 27 '15 at 08:10
  • No..you wont need to do that..I will accessible as `options.MyProp`, give try for it, It follows angular prototypal http://stackoverflow.com/questions/14049480/what-are-the-nuances-of-scope-prototypal-prototypical-inheritance-in-angularjs looks at this – Pankaj Parkar Apr 27 '15 at 08:25