Question

Create a useful page for your project and use four types of data binding. To earn...

Create a useful page for your project and use four types of data binding. To earn points, your examples must be different from the examples from this module.

  1. interpolation binding

  2. attribute binding

  3. event binding

  4. two-way binding

Homework Answers

Answer #1

app.module.ts

import { BrowserModule } from '@angular/platform-browser';

import { NgModule } from '@angular/core';

import { FormsModule } from '@angular/forms';

import { AppRoutingModule } from './app-routing.module';

import { AppComponent } from './app.component';

@NgModule({

declarations: [AppComponent],

imports: [BrowserModule, AppRoutingModule, FormsModule],

providers: [],

bootstrap: [AppComponent]

})

export class AppModule {}

app.component.ts

import { Component } from '@angular/core';

@Component({

selector: 'app-root',

templateUrl: './app.component.html',

styleUrls: [

'./app.component.css',

'../../node_modules/bootstrap/dist/css/bootstrap.min.css'

]

})

export class AppComponent {

//used for string interpolatin

formTitle = 'Login Form';

//used for one way data binding or property binding

username: string = 'admin';

//used for two way data binding

password: string;

// this method will print the values in the console of browser, clicked by event binding

submit() {

console.log('username: ' + this.username);

console.log('password: ' + this.password);

}

}

app.component.html

<div class="container bg-secondary">

<div class="row">

<div class="col-md-6 offset-md-3">

<p class="display-4">Angular Application</p>

<div class="card">

<div class="card-header">

<!-- String interpolation, printing variable formTitle in HTML page. -->

<!-- String interpolation is done as {{ variable }} -->

<h3 class="card-title">{{ formTitle }}</h3>

</div>

<div class="card-body">

<div class="form-group">

<label for="username">Username</label>

<!-- With the help pf property binding, we bind the property "value" of input tag

with the initialValue variable declared in ts file -->

<input

type="text"

id="username"

[value]="username"

class="form-control"

readonly

/>

</div>

<div class="form-group">

<label for="password">Password</label>

<!-- For two way data binding we use [(ngModel)] -->

<!-- Two way data binding is a collection of both property binding and event binding -->

<!-- So if we change it in html it will reflect in ts,and vice versa -->

<input

[(ngModel)]="password"

type="password"

id="password"

class="form-control"

/>

</div>

<!-- With the help of sring interplation printing the typed password -->

<p class="text-warning">Password entered: {{password}}</p>

<!-- With the help of event binding we call function declared in ts file -->

<div class="float-left">

<!-- Here we bind the click event to the submit() function declared in ts file -->

<button class="btn btn-danger" (click)="submit()">Submit</button>

</div>

</div>

</div>

</div>

</div>

</div>

Output:-

--------------------------------------

Please give me a UPVOTE. Thank you :)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
5 -​Create a web page that contains JavaScript code as discussed in class. ​Your page should...
5 -​Create a web page that contains JavaScript code as discussed in class. ​Your page should use the defaults for color, font face and font size. ​Count the numbers from 1 to 50. Skip 1 blank space between each value. You must use a ​for() loop
Take any TWO different data ranges and use VLOOKUP to come up with a useful way...
Take any TWO different data ranges and use VLOOKUP to come up with a useful way to pull the information together. For example, if you have a price list and an order list (in separate locations), you may want to use VLOOKUP to determine how much an order costs (quantity x price). Use VLOOKUP to pull all of the information onto one excel sheet. You must complete the following: 1-Show two separate accounting related data points 2-Effectively use VLOOKUP to...
You are the project manager for an upgrade of computers in your company. You need to...
You are the project manager for an upgrade of computers in your company. You need to upgrade 30 systems, including 10 desktops (for office personnel) and 20 laptops (for remote workers). Each system must access the company network, as well as a common installation of software, security components, and so forth. You must submit your risk identification in a summary that will be used during a presentation for the CIO. In a 3–5 page document, complete the following: Identify four...
Module 06 Course Project - Part 2 Prepare a two to three page written assignment that...
Module 06 Course Project - Part 2 Prepare a two to three page written assignment that includes the following: Content: Prepare a two to three page written assignment that includes the following: Introduction to the assignment (sections of the assignment) Describe the importance of the code of ethics in nursing Identify the American Nurses Association Standards of Practice for the licensure you are obtaining (LPN or RN) Conclusion (reflect on the criteria of the assignment) Use at least two credible...
Create an outline of your project (1 page). The outline should only contain topic headings and...
Create an outline of your project (1 page). The outline should only contain topic headings and a brief description of what it will cover. See the link below for an APA formatted outline. Remember that your outline will be a guide as you write your paper to keep you on topic and organized. Required paragraph topics include but are not limited to: the role nutrition plays in the prevention of the disease, etiology, progression, treatment, recommended diets, nursing assessment, nursing...
C++ Language 1. List any four different data types that have been discussed in class and/or...
C++ Language 1. List any four different data types that have been discussed in class and/or used in your programs. 2. The expression 4 + 6 / 3 * 0 evaluates to 3. Code two different ways to add 1 to a variable called count and have the result stored in count.
Create a poster for a client that is looking for 6 tips on how to improve...
Create a poster for a client that is looking for 6 tips on how to improve their health. Your 6 tips must include information from the whole semester, as well as from 3 different dimensions of health (you can include more than one tip from the same dimension as long as you have information from 3 different dimensions). The information you provide needs to be specific and informative. Your poster should be a single page, include a collection of images,...
Only use C for this problem. To start, create a structure with arrays. Any structure you...
Only use C for this problem. To start, create a structure with arrays. Any structure you decide on is ok, just create your own. That said, you are required to meet these guidelines: 1. You must give the structure you make a name. Any is ok 2. Your structure must have at least 3 members. 3. Two of those members must be arrays. 4. Your members need to be of at least two different data-types. To clarify, your members cannot...
In a two-page paper, research three examples of technologies that use quantum mechanics. Explain, in your...
In a two-page paper, research three examples of technologies that use quantum mechanics. Explain, in your own words, how these applications impact society. If you or someone you know has ever had an MRI scan for a medical diagnosis, you have experienced the result of quantum physics for measuring bodily structures. Finally, provide another specific example from your own life that could be influenced by these applications.
(Use the case of “Global Treps”) You have been selected as the project manager for the...
(Use the case of “Global Treps”) You have been selected as the project manager for the Global Treps project. You helped to run a local shark tank like event at your college last year as part of a class project, so you have a general idea of what is involved. The schedule goal is six months, and the budget is $120,000. Your favorite professor, Dr. K., and a few of her associates have agreed to fund the project. Your strengths...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT