Skip to main content

Two way data binding in angular 2

        Consider angular 1 is a great feature for two-way data binding system. It's very helpful to access a variable in a directive and modifying value shows the user view or web view.

         In this feature is not available in angular > 2.0 greater than version because of here not in a use of the directive structure. So In this feature will implement angular 2 means, we require to know the event and properties binding details.

Properties binding:

[] : -  The behind of the symbol to binding a property in HTML element of view page in angular 2.

Example:

<input type="text" name="firstname" [ngModel] = "firstName">

The above line of code is firstName value is to bind ngModel of an input element.


Event Binding:

(): - The behind of the sysmbol to binding an event in the included HTML element in angular 2.

Example:

<input type="text" name="firstname" [ngModel] = "firstName" (onClick)="changeValue()">

This above line of code is an event bind in input tag for on click method.

Two-Way binding:

The above both bindings are integrated to achieve the two-way data binding in angualar2.

Symbol: [()]

Example:


<form #twowayFrm="ngForm">

<span>Two way Data binding</span><br>

<div class="form-control">

<label> User Name</label>

<input type="text" name="lastname" [(ngModel)]="lastName">
<span>{{lastName}}</span>
</div>
</form>


Comments

Popular posts from this blog

How has lockdown impacted Indian farmers?

How has lockdown impacted Indian farmers?             Generally compare to other sectors it's not major impacted by our Indian farmers but we acceptable minor impacts. Here we separate major two farming cultures one is mono farming culture another one poly farming culture. Mono farming :             The major impacts from our Indian farmer for monoculture. Here I have briefly explained what are the things we had faced our local farmers. Here I explain two different crops type: Daily crops : * We harvest more than 100-kilo grams daily crops like brinjal but we unable to sell those in local markets. * We are unable to reach urban markets. * We don't have enough transport facilities. * We unable buy require fertilizer and other complements * In the early stage we are facing manpower shortage but later it's not an issue. * We unable to do value-added products. * Waste is very high for somedays Se...

Timer Display using AngularJS

Timer Display To display timer in a page means, we need to aware of angular directive as following $interval and $filter . Current time get from new Date() object from native java script.   $interval Directive:  A interval is wait into a millisecond or trigger to a function, This function many many time to repeatedly calling process is control to us.   Syntax:  $interval(fn, delay, [count], [invokeApply]); fn - a function to call repeatedly. Delay – number of millisecond to call a function. Count – Number of time to repeat.(0 value means no-repeat) invoteApply – set to false means it will skip. Example:  HTML: <div ng-app="timerApp">     <div ng-controller="timerController">         {{time}}     </div> </div> JAVAScript: var app = angular.module("timerApp", []); app.controller("timerController",['$scope','$interval...

Fiksu integration by cordova mobile application

Fiksu: A fiksu is a advertisement agency in various media domain. Especially in mobile application side more effectively analysis by mobile users. Their best to do the ads on your application and collective revenue  and pay to the yours. Fiksu Integration Steps:(Install Linux or Ubuntu) 1.  Create an account from fiksu site as following URL https://dashboard.fiksu.com/en/signin . 2.  Singin your credential from this site. 3. Download the fiksu SDK files Download . 4.Then open your terminal and type android command. Open Android SDK manager widget is select Extra package inside play related package list item is select and install it. 5. Now extract fiksu SDK downloaded and get Path details and execute following command. cordova plugin add com.fiksu.sdk --searchpath home/user/Fiksu-SDK-for-Cordova-1.2.0/Library/plugin --noregistry 6. Add the following code from your index.html inside of the javascrip blog. Android: onDeviceReady: function() { ...