I have 1 dropdownlist
and 3 input text
, categories
, title
, name
, type
, at the beginning, I want to hide type
field, then when I choose field title
in categories dropdownlist
, it hides name
and show title
and type
, and when I choose name
it goes hides type
and title
, how can I apply this logic?
in my case it just hides type
because it is false
.
show.component.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="container">
<form id="myform">
<div class="form-group">
<label>Categories <span class="text-hightlight">*</span></label>
<select class="form-control" name="category_id" id="category_id">
<option>select</option>
<option value="1">title</option>
<option value="2">name</option>
</select>
</div>
<div class="form-group">
<label>title <span class="text-hightlight">*</span></label>
<input type="text" name="title" class="form-control"/>
</div>
<div class="form-group" >
<label>name <span class="text-hightlight">*</span></label>
<input type="text" name="name" id="name" class="form-control"/>
</div>
<div class="form-group" *ngIf="show">
<label>type <span class="text-hightlight">*</span></label>
<input type="text" name="type" id="type" class="form-control"/>
</div>
</form>
</div>
</body>
</html>
show.component.ts
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'show',
templateUrl: './show.component.html',
styleUrls: ['./show.component.css']
})
export class ShowComponent implements OnInit {
show:boolean=false;
constructor() { }
ngOnInit(): void {
}
}