EduBw
EduBw

Reputation: 942

Change value in html with angular2

I need to change the value in my HTML ->

For example ->

compontent .ts

public varBoolean: boolean;

HTML->

  1º <a>
     <a  href="http://localhost:8090/download/{{varBoolean}}">
      </a>

    2º<a>

     <a href="http://localhost:8090/download/{{varBoolean}}">
     </a>

in 1º "var" = true; but in my 2º = false. I need that my var have the same name because my server get for name->

  @RequestMapping(method = RequestMethod.GET, path = "/download/{varBoolean}

I have tried with:

1º a http://localhost:8090/download/{{varBoolean=true}}
2º a http://localhost:8090/download/{{varBoolean=false}}

But I get an error :/

Upvotes: 0

Views: 54

Answers (1)

Pratap A.K
Pratap A.K

Reputation: 4517

@RequestMapping(method = RequestMethod.GET, path = "/download/{varBoolean}

doesn't mean that you need to use same "varBoolean" in client side

Wrong

{{varBoolean=true}} will not work because you can't use assignment operator in an interpolation

1º a http://localhost:8090/download/{{varBoolean=true}}
2º a http://localhost:8090/download/{{varBoolean=false}}

what you need instead is

1º a http://localhost:8090/download/true
2º a http://localhost:8090/download/false

So you can use any variable name or any number of variable to keep true of false in your cline side and append path variable to url

If boolean value is dynamic then you can do

component

1DegreeBoolean = true;
2DegreeBoolean = false;

html

1º <a>
     <a  href="http://localhost:8090/download/{{1DegreeBoolean}}">
      </a>

    2º<a>

     <a href="http://localhost:8090/download/{{2DegreeBoolean}}">
     </a>

Upvotes: 2

Related Questions