<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Angular directives &#8211; Sibeesh Passion</title>
	<atom:link href="https://sibeeshpassion.com/tag/angular-directives/feed/" rel="self" type="application/rss+xml" />
	<link>https://sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Tue, 10 Jul 2018 10:41:10 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>Angular directives &#8211; Sibeesh Passion</title>
	<link>https://sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Implement Shared Custom Validator Directive in Angular</title>
		<link>https://sibeeshpassion.com/implement-shared-custom-validator-directive-in-angular/</link>
					<comments>https://sibeeshpassion.com/implement-shared-custom-validator-directive-in-angular/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Sun, 22 Apr 2018 15:21:33 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Angular 5]]></category>
		<category><![CDATA[Angular 5 Validations]]></category>
		<category><![CDATA[Angular directives]]></category>
		<category><![CDATA[Angular Shared Directive]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=12804</guid>

					<description><![CDATA[[toc] Introduction In this post, we are going to see how to create a custom validator directive in Angular 5. We have already seen how to do validation in our previous posts, and we have not done any validations for comparing the password and confirm the password, remember? Here we are going to see that. At the end of this article, you will get to know how to create a new shared directive according to our requirements. This post is a continuation of the course Developing an Angular 5 App series if you haven&#8217;t gone through the previous posts yet, [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>[toc]</p>
<h2>Introduction</h2>
<p>In this post, we are going to see how to create a custom validator directive in <a href="http://sibeeshpassion.com/category/client-side-technologies/angular/">Angular</a> 5. We have already seen how to do validation in our previous posts, and we have not done any validations for comparing the password and confirm the password, remember? Here we are going to see that. At the end of this article, you will get to know how to create a new shared directive according to our requirements<em>.</em> This post is a continuation of the course <em>Developing an Angular 5 App</em> series if you haven&#8217;t gone through the previous posts yet, I strongly recommend you to do that. You can find the links to the previous posts below. I hope you will like this article.</p>
<h2><em>Developing an Angular 5 App</em> series</h2>
<p>These are the previous posts in this series. Please go ahead and have a look.</p>
<ol>
<li><a href="http://sibeeshpassion.com/what-is-new-and-how-to-set-up-our-first-angular-5-application/">What Is New and How to Set Up our First Angular 5 Application</a></li>
<li><a href="http://sibeeshpassion.com/angular-5-basic-demo-project-overview/">Angular 5 Basic Demo Project Overview</a></li>
<li><a href="http://sibeeshpassion.com/generating-your-first-components-and-modules-in-angular-5-app/">Generating Your First Components And Modules in Angular 5 App</a></li>
<li><a href="http://sibeeshpassion.com/implement-validations-in-angular-5-app/">Implement Validations in Angular 5 App</a></li>
<li>Validation Using Template Driven Forms in Angular 5</li>
</ol>
<h2><span id="source-code">Source Code</span></h2>
<p>You can always clone or download the source code <a href="https://github.com/SibeeshVenu/ng5">here</a></p>
<h2>Background</h2>
<p>Validations have a vital role in all application no matter in what language it is been developed. And since it is an essential part, there are many ways to achieve it. If we create a custom shared directive for creating a compare validator, it would be a great piece of code right, which can be reused.</p>
<h2>Using the code</h2>
<p style="text-align: left;">It is recommended to clone the project from GitHub, so that you can try everything your own. Let&#8217;s go ahead and write some codes now.</p>
<h3>Creating a custom directive</h3>
<p>Let&#8217;s just create a new directive in a shared folder and name it <em>equal.validator.directive.ts. </em>Now open that file and start writing the code. Let&#8217;s import some of the core components first.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">import { Validator, AbstractControl, NG_VALIDATORS } from "@angular/forms";
import { Directive, Input } from "@angular/core";</pre>
<p>Now Let&#8217;s define our class and @Directive.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">import { Validator, AbstractControl, NG_VALIDATORS } from "@angular/forms";
import { Directive, Input } from "@angular/core";

@Directive({
    selector: "[appEqualValidator]",
    providers: [{
        provide: NG_VALIDATORS,
        useExisting: EqualValidatorDirective,
        multi: true
    }]
})
export class EqualValidatorDirective implements Validator {
    validate(c: AbstractControl): { [key: string]: any; } {
        throw new Error("Method not implemented.");
    }
    registerOnValidatorChange?(fn: () =&gt; void): void {
        throw new Error("Method not implemented.");
    }
}</pre>
<p>As you can see that, we are actually inheriting our new class  EqualValidatorDirective from Validator. Now we need to change the implementations of the method inside it. We should also add our new directive in app.module.ts file.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule} from '@angular/platform-browser/animations'
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { MatButtonModule, MatCardModule, MatInputModule, MatSnackBarModule, MatToolbarModule } from '@angular/material';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { EqualValidatorDirective } from './shared/equal.validator.directive';

import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { NavComponent } from './nav/nav.component';
import { RegistrationComponent } from './registration/registration.component';
import { LoginComponent } from './login/login.component';

import { AuthService } from './auth.service';
import { AuthGuard } from './auth.guard';

const myRoots: Routes = [
  { path: '', component: HomeComponent, pathMatch: 'full' , canActivate: [AuthGuard]},
  { path: 'register', component: RegistrationComponent },
  { path: 'login', component: LoginComponent},
  { path: 'home', component: HomeComponent, canActivate: [AuthGuard]}
];

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent,
    NavComponent,
    RegistrationComponent,
    LoginComponent,
    EqualValidatorDirective
  ],
  imports: [
    BrowserModule, BrowserAnimationsModule, FormsModule, ReactiveFormsModule,
    MatButtonModule, MatCardModule, MatInputModule, MatSnackBarModule, MatToolbarModule,
    RouterModule.forRoot(myRoots)
  ],
  providers: [AuthService, AuthGuard],
  bootstrap: [AppComponent]
})
export class AppModule { }
</pre>
<p>&nbsp;</p>
<h3>Implement validate</h3>
<p>Before we do that, we should add our new cutom directive selector in our confirm password field, because that&#8217;s where we are going to use our validator. So we are going to change our markup for confirm password field as below.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">&lt;div class="form-group" [class.has-error]="confirmPasswordControl.invalid &amp;&amp; confirmPasswordControl.touched" [class.has-success]="confirmPasswordControl.valid"&gt;
    &lt;input type="password" required class="form-control" name="confirmPassword" appEqualValidator="password" placeholder="Confirm Password" [(ngModel)]="confirmPassword" #confirmPasswordControl="ngModel"&gt;
    &lt;span class="help-block" *ngIf="confirmPasswordControl.errors?.required &amp;&amp; confirmPasswordControl.touched"&gt;
                  Confirm password is required
                &lt;/span&gt;
&lt;/div&gt;</pre>
<p>As you can see, we are using the selector  <em>appEqualValidator=&#8221;password&#8221; </em>in our confirm password field. Please do check my previous posts if you are not sure how to implement other validations like email and required.</p>
<p>Now let&#8217;s go back to our custom directive and make some changes.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">export class EqualValidatorDirective implements Validator {
    @Input() appEqualValidator: string;
    validate(c: AbstractControl): { [key: string]: any; } {
        const controlToCompare = c.parent.get(this.appEqualValidator)
        if (controlToCompare &amp;&amp; controlToCompare.value == c.value)return { "equal": true };
        return { "notEqual": true }
    }
    registerOnValidatorChange?(fn: () =&gt; void): void {
        throw new Error("Method not implemented.");
    }
}</pre>
<p>Here, we get our confirmPassword control in the absolute control &#8220;c&#8221;, and in the next line, we are just finding our password control by getting the parent element of confirmPassword. Once we get that, we can easily perform the comparison easily right? So, if it matches we return  { &#8220;equal&#8221;: true }; or else { &#8220;notEqual&#8221;: true }. Sounds good?</p>
<h3>Introduce new span for custom message</h3>
<p>Now we have a custom validator which compares two values, and the only thing which pending is, that to create a span for showing our new message in UI. Let&#8217;s change our markup now.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="html">&lt;div class="form-group" [class.has-error]="confirmPasswordControl.invalid &amp;&amp; confirmPasswordControl.touched" [class.has-success]="confirmPasswordControl.valid"&gt;
    &lt;input type="password" required class="form-control" name="confirmPassword" appEqualValidator="password" placeholder="Confirm Password" [(ngModel)]="confirmPassword" #confirmPasswordControl="ngModel"&gt;
    &lt;span class="help-block" *ngIf="confirmPasswordControl.errors?.required &amp;&amp; confirmPasswordControl.touched"&gt;
                  Confirm password is required
                &lt;/span&gt;
    &lt;span class="help-block" *ngIf="confirmPasswordControl.errors?.notEqual 
                      &amp;&amp; confirmPasswordControl.touched &amp;&amp; !confirmPasswordControl.errors?.required"&gt;
                  Password doesn't match
                &lt;/span&gt;
&lt;/div&gt;</pre>
<p>As you can see, we are showing the custom message only if the directive returns notEqual property and there are no required errors. Let&#8217;s run our application and see it in action.</p>
<p><a href="https://sibeeshpassion.com/wp-content/uploads/2018/04/Custom-Shared-Equal-Validator-Directive.jpg"><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-12805" src="https://sibeeshpassion.com/wp-content/uploads/2018/04/Custom-Shared-Equal-Validator-Directive.jpg" alt="" width="384" height="529" srcset="/wp-content/uploads/2018/04/Custom-Shared-Equal-Validator-Directive.jpg 259w, /wp-content/uploads/2018/04/Custom-Shared-Equal-Validator-Directive-218x300.jpg 218w" sizes="(max-width: 384px) 100vw, 384px" /></a></p>
<p>&nbsp;</p>
<p>Here we have seen how we can implement shared custom validator directive. Let&#8217;s connect to a database and save these values in next article. Till then, bye.</p>
<h2><span id="conclusion">Conclusion</span></h2>
<p>Thanks a lot for reading. Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<h2><span id="your-turn-what-do-you-think">Your turn. What do you think?</span></h2>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/implement-shared-custom-validator-directive-in-angular/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How To Create Dynamic Angular JS Tabs In MVC</title>
		<link>https://sibeeshpassion.com/how-to-create-dynamic-angular-js-tabs-in-mvc/</link>
					<comments>https://sibeeshpassion.com/how-to-create-dynamic-angular-js-tabs-in-mvc/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Tue, 16 Feb 2016 00:00:20 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Angular directives]]></category>
		<category><![CDATA[Angular JS]]></category>
		<category><![CDATA[Angular JS Tabs]]></category>
		<category><![CDATA[MVC]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=11214</guid>

					<description><![CDATA[In this post we will see how we can create Angular JS dynamics tabs in MVC application. As you all are aware of that we have a tab control in Angular JS, here we are going to see how those tabs can be created dynamically with some dynamic data, these dynamic data can be fetched from database. Here I am creating some dynamic data accordingly for making this article easy to understand. We will be creating Angular JS app, controller, service to fetch the data from our MVC controller. Once that is done, we will format the data and assign [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this post we will see how we can create <a href="http://sibeeshpassion.com/category/angularjs/" target="_blank">Angular JS </a>dynamics tabs in <a href="http://sibeeshpassion.com/category/mvc/" target="_blank">MVC </a>application. As you all are aware of that we have a tab control in Angular JS, here we are going to see how those tabs can be created dynamically with some dynamic data, these dynamic data can be fetched from database. Here I am creating some dynamic data accordingly for making this article easy to understand. We will be creating Angular JS app, controller, service to fetch the data from our MVC controller. Once that is done, we will format the data and assign it to the tab control. Sounds good?. I hope you will like this article. </p>
<p><strong>Download Source Code</strong></p>
<p>Download the source code from here: <a href="https://code.msdn.microsoft.com/Dynamic-Angular-JS-Tabs-In-a39d1966" target="_blank">Dynamic Angular JS Tabs In MVC</a></p>
<p><strong>Background</strong></p>
<p>Recently I have got a requirement to create a tab control in one of my Angular JS application. Then I thought of creating the same dynamically according to the user needs. This article is a demo of the same.</p>
<p><strong>Using the code</strong></p>
<p>First, we will start with creating an MVC application. Open your visual studio, then click File->New->Project. Name your project. </p>
<p>Now our application is launched, please go ahead and install Angular JS in your project from NuGet packages. You can see some new CSS files and scripts has been added to our project. So the set up has been done. Now what we need to do is to move on the coding part. </p>
<p><strong>Create a controller </strong></p>
<p>Now we can create a new controller, in my case I created a controller &#8216;HomeController&#8217;. In my controller I am going to call a model action which will return some dynamic data. See the code below. </p>
<p>[csharp]<br />
public class HomeController : Controller<br />
    {<br />
        //<br />
        // GET: /Home/</p>
<p>         public ActionResult Index()<br />
        {<br />
            return View();<br />
        }<br />
        public JsonResult TabData()<br />
        {<br />
            Test t = new Test();<br />
            var myList = t.GetData();<br />
            return Json(myList, JsonRequestBehavior.AllowGet);<br />
        }</p>
<p>    }<br />
[/csharp]</p>
<p>Here we have one ActionResult and one JsonResult which we are going to call as Angular JS service. As you can see I am creating an instance of my model Test, now we will create our model class. Shall we?</p>
<p><strong>Create Model </strong></p>
<p>I have create a model class with the name Test. Here I am creating some data dynamically using a for loop and assign those values to a list. Please see the codes below. </p>
<p>[csharp]<br />
namespace AsyncActions.Models<br />
{<br />
    public class Test<br />
    {<br />
        public List&lt;Customer&gt; GetData()<br />
        {<br />
            try<br />
            {<br />
                List&lt;Customer&gt; cst = new List&lt;Customer&gt;();<br />
                for (int i = 0; i &lt; 15; i++)<br />
                {<br />
                    Customer c = new Customer();<br />
                    c.CustomerID = i;<br />
                    c.CustomerCode = &quot;CST&quot; + i;<br />
                    cst.Add(c);<br />
                }<br />
                return cst;<br />
            }<br />
            catch (Exception)<br />
            {<br />
                throw new NotImplementedException();<br />
            }</p>
<p>        }<br />
    }<br />
    public class Customer<br />
    {<br />
        public int CustomerID { get; set; }<br />
        public string CustomerCode { get; set; }<br />
    }<br />
}<br />
[/csharp]</p>
<p>As you can see I am creating a list of type Customer. Is that fine? Now what is pending? Yes, a view.</p>
<p><strong>Create a view</strong></p>
<p>Right click on your controller and click add view, that will give you a new view in your view folder. Hope you get that.</p>
<p>So our view is ready, now we can do some codes in our view to populate our tab. Are you ready?</p>
<p>[html]<br />
&lt;div ng-controller=&quot;tabController&quot; class=&quot;sample tabsdemoDynamicTabs&quot; layout=&quot;column&quot; ng-cloak=&quot;&quot; ng-app=&quot;tab&quot;&gt;<br />
    &lt;md-content class=&quot;md-padding&quot;&gt;<br />
    &lt;md-tabs md-selected=&quot;selectedIndex&quot; md-border-bottom=&quot;&quot; md-autoselect=&quot;&quot;&gt;<br />
      &lt;md-tab ng-repeat=&quot;tab in tabs&quot; ng-disabled=&quot;tab.disabled&quot; label=&quot;{{tab.title}}&quot;&gt;<br />
        &lt;div class=&quot;demo-tab tab{{$index}}&quot; style=&quot;padding: 25px; text-align: center;&quot;&gt;<br />
          &lt;div ng-bind=&quot;tab.content&quot;&gt;&lt;/div&gt;<br />
          &lt;br&gt;<br />
          &lt;md-button class=&quot;md-primary md-raised&quot; ng-click=&quot;removeTab( tab )&quot; ng-disabled=&quot;tabs.length &lt;= 1&quot;&gt;Remove Tab&lt;/md-button&gt;<br />
        &lt;/div&gt;<br />
      &lt;/md-tab&gt;<br />
    &lt;/md-tabs&gt;<br />
  &lt;/md-content&gt;<br />
    &lt;form ng-submit=&quot;addTab(tTitle,tContent)&quot; layout=&quot;column&quot; class=&quot;md-padding&quot; style=&quot;padding-top: 0;&quot;&gt;<br />
        &lt;div layout=&quot;row&quot; layout-sm=&quot;column&quot;&gt;<br />
            &lt;div flex=&quot;&quot; style=&quot;position: relative;&quot;&gt;<br />
                &lt;h2 class=&quot;md-subhead&quot; style=&quot;position: absolute; bottom: 0; left: 0; margin: 0; font-weight: 500; text-transform: uppercase; line-height: 35px; white-space: nowrap;&quot;&gt;Add a new Tab:&lt;/h2&gt;<br />
            &lt;/div&gt;<br />
            &lt;md-input-container&gt;<br />
        &lt;label for=&quot;label&quot;&gt;Label&lt;/label&gt;<br />
        &lt;input type=&quot;text&quot; id=&quot;label&quot; ng-model=&quot;tTitle&quot;&gt;<br />
      &lt;/md-input-container&gt;<br />
            &lt;md-input-container&gt;<br />
        &lt;label for=&quot;content&quot;&gt;Content&lt;/label&gt;<br />
        &lt;input type=&quot;text&quot; id=&quot;content&quot; ng-model=&quot;tContent&quot;&gt;<br />
      &lt;/md-input-container&gt;<br />
            &lt;md-button class=&quot;add-tab md-primary md-raised&quot; ng-disabled=&quot;!tTitle || !tContent&quot; type=&quot;submit&quot; style=&quot;margin-right: 0;&quot;&gt;Add Tab&lt;/md-button&gt;<br />
        &lt;/div&gt;<br />
    &lt;/form&gt;<br />
&lt;/div&gt;<br />
[/html]</p>
<p>As you can see we are declaring our angular js controller and app name as follows.</p>
<p>[html]<br />
ng-controller=&quot;tabController&quot; class=&quot;sample tabsdemoDynamicTabs&quot; layout=&quot;column&quot; ng-cloak=&quot;&quot; ng-app=&quot;tab&quot;<br />
[/html]</p>
<p>Now we will add the needed reference to our view. </p>
<p><strong>Add the style sheet references</strong></p>
<p>[html]<br />
&lt;link href=&quot;~/CSS/angular-material.css&quot; rel=&quot;stylesheet&quot; /&gt;<br />
&lt;link href=&quot;~/CSS/docs.css&quot; rel=&quot;stylesheet&quot; /&gt;<br />
[/html]</p>
<p><strong>Add styles for tabs</strong></p>
<p>[css]<br />
&lt;style&gt;<br />
    .tabsdemoDynamicTabs md-content {<br />
        background-color: transparent !important;<br />
    }</p>
<p>        .tabsdemoDynamicTabs md-content md-tabs {<br />
            border: 1px solid #e1e1e1;<br />
        }</p>
<p>            .tabsdemoDynamicTabs md-content md-tabs md-tab-content {<br />
                background: #f6f6f6;<br />
            }</p>
<p>            .tabsdemoDynamicTabs md-content md-tabs md-tabs-wrapper {<br />
                background: white;<br />
            }</p>
<p>        .tabsdemoDynamicTabs md-content h1:first-child {<br />
            margin-top: 0;<br />
        }</p>
<p>    .tabsdemoDynamicTabs md-input-container {<br />
        padding-bottom: 0;<br />
    }</p>
<p>    .tabsdemoDynamicTabs .remove-tab {<br />
        margin-bottom: 40px;<br />
    }</p>
<p>    .tabsdemoDynamicTabs .demo-tab &gt; div &gt; div {<br />
        padding: 25px;<br />
        box-sizing: border-box;<br />
    }</p>
<p>    .tabsdemoDynamicTabs .edit-form input {<br />
        width: 100%;<br />
    }</p>
<p>    .tabsdemoDynamicTabs md-tabs {<br />
        border-bottom: 1px solid rgba(0, 0, 0, 0.12);<br />
    }</p>
<p>    .tabsdemoDynamicTabs md-tab[disabled] {<br />
        opacity: 0.5;<br />
    }</p>
<p>    .tabsdemoDynamicTabs label {<br />
        text-align: left;<br />
    }</p>
<p>    .tabsdemoDynamicTabs .long &gt; input {<br />
        width: 264px;<br />
    }</p>
<p>    .tabsdemoDynamicTabs .md-button.add-tab {<br />
        transform: translateY(5px);<br />
    }<br />
&lt;/style&gt;<br />
[/css]</p>
<p><strong>Add the JS references</strong></p>
<p>[html]<br />
&lt;script src=&quot;~/Scripts/angular.min.js&quot;&gt;&lt;/script&gt;<br />
&lt;script src=&quot;~/Scripts/angular-animate.min.js&quot;&gt;&lt;/script&gt;<br />
&lt;script src=&quot;~/Scripts/angular-route.js&quot;&gt;&lt;/script&gt;<br />
&lt;script src=&quot;~/Scripts/angular-aria.min.js&quot;&gt;&lt;/script&gt;<br />
&lt;script src=&quot;~/Scripts/angular-messages.min.js&quot;&gt;&lt;/script&gt;<br />
&lt;script src=&quot;~/Scripts/svg-assets-cache.js&quot;&gt;&lt;/script&gt;<br />
&lt;script src=&quot;~/Scripts/angular-material.js&quot;&gt;&lt;/script&gt;<br />
&lt;script src=&quot;~/Scripts/Module.js&quot;&gt;&lt;/script&gt;<br />
[/html]</p>
<p>Here Module.js is the file where we are creating our Angular JS controller, Service, App. So can we go ahead and create those?</p>
<p><strong>Create an app, controller, service in Angular JS</strong></p>
<p>To add an app, controller, servicer in Angular JS, you need to add the codes as below. </p>
<p>[js]<br />
(function () {<br />
    &#8216;use strict&#8217;;<br />
    var app;<br />
    (function () {<br />
        //create app<br />
        app = angular.module(&quot;tab&quot;, [&#8216;ngMaterial&#8217;, &#8216;ngMessages&#8217;, &#8216;material.svgAssetsCache&#8217;]);<br />
        //create controller<br />
        app.controller(&#8216;tabController&#8217;, function ($scope, tabService) {<br />
            var serv = tabService.getAll();<br />
            serv.then(function (d) {<br />
                tabController(d.data, $scope);<br />
            }, function (error) {<br />
                console.log(&#8216;Something went wrong, please check after a while&#8217;);<br />
            })<br />
        });<br />
        //create service<br />
        app.service(&#8216;tabService&#8217;, function ($http) {<br />
            this.getAll = function () {<br />
               return $http({<br />
                    url: &quot;/Home/TabData&quot;, //Here we are calling our controller JSON action<br />
                    method: &quot;GET&quot;<br />
                });<br />
            };<br />
        });<br />
    })();<br />
})();<br />
[/js]</p>
<p>As you can see once we get the data from the Angular JS service (tabService) to the controller (tabController), we are passing the data to a function named tabController. Below is the code for that function. </p>
<p>[js]<br />
function tabController(data, $scope) {<br />
        var tabsArray = [];<br />
        for (var i = 0; i &lt; data.length; i++) {<br />
            tabsArray.push(<br />
                {<br />
                    &#8216;title&#8217;:&quot;Customer ID: &quot;+ data[i].CustomerID,<br />
                    &#8216;content&#8217;: data[i].CustomerCode + &quot; The data you are seeing here is for the customer with the Custome rCode &quot; + data[i].CustomerCode<br />
                });<br />
        }<br />
        var tabs = tabsArray,<br />
            selected = null,<br />
            previous = null;<br />
        $scope.tabs = tabs;<br />
        $scope.selectedIndex = 0;<br />
        $scope.$watch(&#8216;selectedIndex&#8217;, function (current, old) {<br />
            previous = selected;<br />
            selected = tabs[current];<br />
        });<br />
        $scope.addTab = function (title, view) {<br />
            view = view || title + &quot; Content View&quot;;<br />
            tabs.push({ title: title, content: view, disabled: false });<br />
        };<br />
        $scope.removeTab = function (tab) {<br />
            var index = tabs.indexOf(tab);<br />
            tabs.splice(index, 1);<br />
        };<br />
    }<br />
[/js]</p>
<p>That&#8217;s all we have created the Angular JS tabs dynamically. Shall we see the output now?</p>
<p><strong>Output</strong></p>
<div id="attachment_11215" style="width: 644px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2016/02/Dynamic-Angular-JS-Tabs-In-MVC-Figure-1.png"><img decoding="async" aria-describedby="caption-attachment-11215" src="http://sibeeshpassion.com/wp-content/uploads/2016/02/Dynamic-Angular-JS-Tabs-In-MVC-Figure-1-1024x232.png" alt="Dynamic Angular JS Tabs In MVC Figure 1" width="634" height="144" class="size-large wp-image-11215" srcset="/wp-content/uploads/2016/02/Dynamic-Angular-JS-Tabs-In-MVC-Figure-1-1024x232.png 1024w, /wp-content/uploads/2016/02/Dynamic-Angular-JS-Tabs-In-MVC-Figure-1-300x68.png 300w, /wp-content/uploads/2016/02/Dynamic-Angular-JS-Tabs-In-MVC-Figure-1-768x174.png 768w, /wp-content/uploads/2016/02/Dynamic-Angular-JS-Tabs-In-MVC-Figure-1-400x91.png 400w, /wp-content/uploads/2016/02/Dynamic-Angular-JS-Tabs-In-MVC-Figure-1.png 1918w" sizes="(max-width: 634px) 100vw, 634px" /></a><p id="caption-attachment-11215" class="wp-caption-text">Dynamic Angular JS Tabs In MVC Figure 1</p></div>
<div id="attachment_11216" style="width: 644px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2016/02/Dynamic-Angular-JS-Tabs-In-MVC-Figure-2.png"><img decoding="async" aria-describedby="caption-attachment-11216" src="http://sibeeshpassion.com/wp-content/uploads/2016/02/Dynamic-Angular-JS-Tabs-In-MVC-Figure-2-1024x249.png" alt="Dynamic Angular JS Tabs In MVC Figure 2" width="634" height="154" class="size-large wp-image-11216" srcset="/wp-content/uploads/2016/02/Dynamic-Angular-JS-Tabs-In-MVC-Figure-2-1024x249.png 1024w, /wp-content/uploads/2016/02/Dynamic-Angular-JS-Tabs-In-MVC-Figure-2-300x73.png 300w, /wp-content/uploads/2016/02/Dynamic-Angular-JS-Tabs-In-MVC-Figure-2-768x187.png 768w, /wp-content/uploads/2016/02/Dynamic-Angular-JS-Tabs-In-MVC-Figure-2-400x97.png 400w, /wp-content/uploads/2016/02/Dynamic-Angular-JS-Tabs-In-MVC-Figure-2.png 1917w" sizes="(max-width: 634px) 100vw, 634px" /></a><p id="caption-attachment-11216" class="wp-caption-text">Dynamic Angular JS Tabs In MVC Figure 2</p></div>
<p><strong>References</strong></p>
<p><a href="https://material.angularjs.org/latest/demo/tabs" target="_blank">Angular JS Tabs</a></p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn&#8217;t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/how-to-create-dynamic-angular-js-tabs-in-mvc/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Basics of AngularJS</title>
		<link>https://sibeeshpassion.com/basics-of-angularjs/</link>
					<comments>https://sibeeshpassion.com/basics-of-angularjs/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Sun, 29 Mar 2015 20:17:54 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Angular directives]]></category>
		<category><![CDATA[Angular JS]]></category>
		<category><![CDATA[Angular JS scopes]]></category>
		<category><![CDATA[Angular JS steps]]></category>
		<category><![CDATA[Angular methods]]></category>
		<category><![CDATA[Basics of Angular JS]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=1531</guid>

					<description><![CDATA[[toc] Introduction In this post we are going to discuss about AngularJS Most of you are familiar with the word AngularJS. This article is for those beginners that have not yet tried to implement AngularJS. Download the source code Basics of AngularJS What Angular JS is? AngularJS has been introduced by the giant Google. It is a framework that helps you create dynamic web apps. Normally AngularJS uses HTML as the backbone. AngularJS creates extended HTML tags that can be used as normal HTML tags. These tags will help you to write efficient code. The interesting fact is you can [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>[toc]</p>
<h3>Introduction</h3>
<p>In this post we are going to discuss about <a href="http://sibeeshpassion.com/category/angularjs/" target="_blank">AngularJS</a> Most of you are familiar with the word AngularJS. This article is for those beginners that have not yet tried to implement AngularJS.</p>
<h3>Download the source code</h3>
<li><a href="https://code.msdn.microsoft.com/Basics-of-AngularJS-fb1d9df2" target="_blank">Basics of AngularJS</a></li>
<h3>What Angular JS is?</h3>
<p>AngularJS has been introduced by the giant Google. It is a framework that helps you create dynamic web apps. Normally AngularJS uses HTML as the backbone. AngularJS creates extended HTML tags that can be used as normal HTML tags. These tags will help you to write efficient code. The interesting fact is you can reduce lines of codes you may need to write when you use normal JavaScript.</p>
<h3>Using the code</h3>
<p>So let&#8217;s start using AngularJS. What would be the first step you need to do? That would be to include the relevant JavaScript file as the following.</p>
<p>[js]<br />
&lt;script src=“~/Script/angular.min.js”&gt;&lt;/script&gt;<br />
[/js]</p>
<p>Once you include this file, you are free to enter the world of AngularJS. You can download that file from <a href="https://angularjs.org/">https://angularjs.org/</a></p>
<h4>Basic Directives</h4>
<p>There are some basic directives that you must be aware of in AngularJS. Those are,</p>
<ul>
<li>ng-app</li>
<li>ng-init</li>
<li>ng-model</li>
<li>ng-repeat</li>
</ul>
<p>We will discuss them. Let&#8217;s start with a basic example.</p>
<p>As I said before, AngularJS uses our HTML to work. So here we will create HTML with minimal tags. Are you ready?</p>
<p>[html]<br />
&lt;div ng-app&gt;<br />
    &lt;p&gt;My name is : {{“Please make me upper case letter”.toUpperCase()}}&lt;/p&gt;<br />
&lt;/div&gt;<br />
[/html]</p>
<p>In the preceding example we added the tag ng-app, right? So what is ng-app?</p>
<h4>ng-app</h4>
<p>The ng-app tag indicates the root element of our angular application. It normally acts as the owner of the application. We can use AngularJS only after the declaration of this tag. The important point to remember is that we can&#8217;t use AngularJS before this tag. We will explain this with an example.</p>
<p>What if we add a calculation of two numbers before the ng-app tag? We will check it out.</p>
<p>[html]<br />
&lt;p&gt;Add me please: 2+2: {{ 2+2 }}&lt;/p&gt;<br />
&lt;div ng-app&gt;<br />
    &lt;p&gt;My name is : {{“Please make me upper case letter”.toUpperCase()}}&lt;/p&gt;<br />
&lt;/div&gt;<br />
[/html]</p>
<p>What would be the output of this? Any guess?</p>
<div id="attachment_12330" style="width: 523px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/03/12.png"><img decoding="async" aria-describedby="caption-attachment-12330" src="http://sibeeshpassion.com/wp-content/uploads/2015/03/12.png" alt="Basics of Angular JS Image 1" width="513" height="177" class="size-full wp-image-12330" srcset="/wp-content/uploads/2015/03/12.png 513w, /wp-content/uploads/2015/03/12-300x104.png 300w, /wp-content/uploads/2015/03/12-400x138.png 400w" sizes="(max-width: 513px) 100vw, 513px" /></a><p id="caption-attachment-12330" class="wp-caption-text">Basics of Angular JS Image 1</p></div>
<p>So what we need to make this work? For that you must put the code after the ng-app declaration. Can we try that? So our modified code would be as follows.</p>
<p>[html]<br />
&lt;div ng-app&gt;<br />
    &lt;p&gt;My name is : {{“Please make me upper case letter”.toUpperCase()}}&lt;/p&gt;<br />
&lt;p&gt;Add me please: 2+2: {{ 2+2 }}&lt;/p&gt;<br />
[/html]</p>
<p>Now our output is as preceding.</p>
<div id="attachment_12331" style="width: 541px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-2.png"><img decoding="async" aria-describedby="caption-attachment-12331" src="http://sibeeshpassion.com/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-2.png" alt="Basics of Angular JS Image 2" width="531" height="170" class="size-full wp-image-12331" srcset="/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-2.png 531w, /wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-2-300x96.png 300w, /wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-2-400x128.png 400w" sizes="(max-width: 531px) 100vw, 531px" /></a><p id="caption-attachment-12331" class="wp-caption-text">Basics of Angular JS Image 2</p></div>
<p>Well, that was the introduction to the directive ng-app. I hope you tried it. Now we will move on to the next one. What is it?</p>
<h4>ng-init</h4>
<p>As the name implies, ng-init is used to initialize the data of our AngularJS. We will try a demo. So the following is my HTML.</p>
<p>[html]<br />
&lt;div ng-init=“myFavoriteWebsites=[‘http://www.c-sharpcorner.com/’,’http://www.codeproject.com/’,’http://sibeeshpassion.com/’]”&gt;<br />
        My First fav website is : {{myFavoriteWebsites[0]}}<br />
        &lt;br /&gt;<br />
        My Second fav website is : {{myFavoriteWebsites[1]}}<br />
        &lt;br /&gt;<br />
        My Third fav website is : {{myFavoriteWebsites[2]}}<br />
    &lt;/div&gt;<br />
[/html]</p>
<p>Please note that I have used the ng-init tag after the ng-app tag. Now can you guess what the output would be?</p>
<div id="attachment_12332" style="width: 495px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-3.png"><img decoding="async" aria-describedby="caption-attachment-12332" src="http://sibeeshpassion.com/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-3.png" alt="Basics of Angular JS Image 3" width="485" height="236" class="size-full wp-image-12332" srcset="/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-3.png 485w, /wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-3-300x146.png 300w, /wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-3-400x195.png 400w" sizes="(max-width: 485px) 100vw, 485px" /></a><p id="caption-attachment-12332" class="wp-caption-text">Basics of Angular JS Image 3</p></div>
<p>I hope you understand what exactly ng-init tag is. Now we will see ng-model.</p>
<h4>ng-model</h4>
<p>Basically the ng-model directive binds the values from our HTML controls to our application data. Sounds good, right?</p>
<p>[html]<br />
Currency in INR: &lt;input type=“number” ng-model=“curinr” /&gt;<br />
&lt;br /&gt;<br />
Currency in Dollar: {{curinr*62.27}}<br />
[/html]</p>
<p>In the preceding example, we are using ng-model “curinr” and we are accessing that in our application data. In this process, whenever you type any value into the number box area, in a fraction of time you can see the calculated value. That is the power of AngularJS.</p>
<div id="attachment_12333" style="width: 356px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-4.jpg"><img decoding="async" aria-describedby="caption-attachment-12333" src="http://sibeeshpassion.com/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-4.jpg" alt="Basics of Angular JS Image 4" width="346" height="280" class="size-full wp-image-12333" srcset="/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-4.jpg 346w, /wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-4-300x243.jpg 300w" sizes="(max-width: 346px) 100vw, 346px" /></a><p id="caption-attachment-12333" class="wp-caption-text">Basics of Angular JS Image 4</p></div>
<p>So I hope you understood how to use the ng-model directive. Now it is time to move on to our next directive, ng-repeat.</p>
<h4>ng-repeat</h4>
<p>This directive is used for looping through a collection or array just like we use a foreach loop in C#. Sounds pretty cool, right? It clones the HTML elements once for each item in the collection.</p>
<p>To work with ng-repeat we will see our previous example. We will modify that example as follows:</p>
<p>[html]<br />
&lt;div ng-init=“myFavoriteWebsites=[‘http://www.c-sharpcorner.com/’,’http://www.codeproject.com/’,’http://sibeeshpassion.com/’]”&gt;<br />
        &lt;ul&gt;<br />
            My favorite websites are:<br />
            &lt;li ng-repeat=“n in myFavoriteWebsites”&gt;<br />
                {{n}}<br />
            &lt;/li&gt;<br />
        &lt;/ul&gt;<br />
    &lt;/div&gt;<br />
[/html]</p>
<p>Now see the output below. With less lines of codes we have done this process. That is all about the ng-repeat directive. I hope you liked it.</p>
<div id="attachment_12334" style="width: 448px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-5.jpg"><img decoding="async" aria-describedby="caption-attachment-12334" src="http://sibeeshpassion.com/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-5.jpg" alt="Basics of Angular JS Image 5" width="438" height="494" class="size-full wp-image-12334" srcset="/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-5.jpg 317w, /wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-5-266x300.jpg 266w, /wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-5-400x451.jpg 400w" sizes="(max-width: 438px) 100vw, 438px" /></a><p id="caption-attachment-12334" class="wp-caption-text">Basics of Angular JS Image 5</p></div>
<p>When you write any code, it must be light weight, efficient and easy right? If it is not easy, someone who looks at your code will be</p>
<div id="attachment_12335" style="width: 215px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-6.jpg"><img decoding="async" aria-describedby="caption-attachment-12335" src="http://sibeeshpassion.com/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-6.jpg" alt="Basics of Angular JS Image 6" width="205" height="246" class="size-full wp-image-12335" /></a><p id="caption-attachment-12335" class="wp-caption-text">Basics of Angular JS Image 6</p></div>
<p>So we have controllers.</p>
<h3>What is controllers?</h3>
<p>Angular JS controllers are Java script object. Simple . The main functionality of this object is controlling the data of our angular application. Sounds cool right?</p>
<p>The directive used here is <em>ng-controller</em>.</p>
<p>In the previous section we used ng-model right? We have seen an example too. Now we will reuse that example here.</p>
<p>The following is the example we done with ng-model</p>
<p>[html]<br />
Currency in INR: &lt;input type=“number” ng-model=“curinr” /&gt;<br />
&lt;br /&gt;<br />
Currency in Dollar: {{curinr*62.27}}<br />
[/html]</p>
<p>No we will change it to as follows.</p>
<p>[html]<br />
&lt;b&gt;ng-Controller&lt;/b&gt;&lt;br /&gt;<br />
&lt;div &gt;<br />
Currency in INR:<br />
&lt;input type=“number” ng-model=“inrvalue” /&gt;<br />
&lt;br /&gt;<br />
Currency in Dollar: {{inrToDollar()}}<br />
&lt;/div&gt;<br />
[/html]</p>
<p>In the above piece of code you can find a new directive ng-controller and I have assigned a valueInrToDollar . So our next step is to create that controller.</p>
<p>We can create a controller as follows.</p>
<p>[js]<br />
var my = angular.module(‘angularBasic’, []);<br />
[/js]</p>
<p>Here &#8216;angularBasic&#8217; is our application name. The complete code for creating our controller is as follows.</p>
<p>[js]<br />
&lt;script&gt;<br />
var my = angular.module(‘angularBasic’, []);<br />
my.controller(‘InrToDollar’, function ($scope) {<br />
$scope.inrToDollar = function () {<br />
return $scope.inrvalue * 62.27;<br />
}<br />
});<br />
&lt;/script&gt;<br />
[/js]</p>
<p>What is <em>$scope </em>in the above code block?</p>
<p><em>$scope</em> is a part of controller. Every controller must have its own $scope object. Here what exactly our controller do is setting the behaviors on $scope.</p>
<p>In the above code block we used a function which returns a dollar value for the given Indian rupee. I have given the function body inside of our controller.</p>
<p>No what would be our output?</p>
<div id="attachment_12336" style="width: 379px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-7.png"><img decoding="async" aria-describedby="caption-attachment-12336" src="http://sibeeshpassion.com/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-7.png" alt="Basics of Angular JS Image 7" width="369" height="90" class="size-full wp-image-12336" srcset="/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-7.png 369w, /wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-7-300x73.png 300w" sizes="(max-width: 369px) 100vw, 369px" /></a><p id="caption-attachment-12336" class="wp-caption-text">Basics of Angular JS Image 7</p></div>
<div id="attachment_12337" style="width: 402px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-8.png"><img decoding="async" aria-describedby="caption-attachment-12337" src="http://sibeeshpassion.com/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-8.png" alt="Basics of Angular JS Image 8" width="392" height="122" class="size-full wp-image-12337" srcset="/wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-8.png 392w, /wp-content/uploads/2015/03/Basics-of-Angular-JS-Image-8-300x93.png 300w" sizes="(max-width: 392px) 100vw, 392px" /></a><p id="caption-attachment-12337" class="wp-caption-text">Basics of Angular JS Image 8</p></div>
<p>Now think if you are using normal java script and jquery for doing this task, how many lines of codes you may need to write?</p>
<h3>Complete Code</h3>
<p>[html]<br />
@{<br />
ViewBag.Title = “Index”;<br />
}<br />
&lt;h2&gt;Index&lt;/h2&gt;<br />
&lt;b&gt;ng-app&lt;/b&gt;<br />
&lt;br /&gt;<br />
&lt;div ng-app=“angularBasic” ng-controller=“InrToDollar”&gt;<br />
&lt;p&gt;My name is : {{“Please make me upper case letter”.toUpperCase()}}&lt;/p&gt;<br />
&lt;p&gt;Add me please: 2+2: {{ 2+2 }}&lt;/p&gt;<br />
&lt;b&gt;ng-init&lt;/b&gt;&lt;br /&gt;<br />
&lt;div ng-init=“myFavoriteWebsites=[‘http://www.c-sharpcorner.com/’,’http://www.codeproject.com/’,’http://sibeeshpassion.com/’]”&gt;<br />
My First fav website is : {{myFavoriteWebsites[0]}}<br />
&lt;br /&gt;<br />
My Second fav website is : {{myFavoriteWebsites[1]}}<br />
&lt;br /&gt;<br />
My Third fav website is : {{myFavoriteWebsites[2]}}<br />
&lt;/div&gt;<br />
&lt;br /&gt;<br />
&lt;b&gt;ng-model&lt;/b&gt;&lt;br /&gt;<br />
Currency in INR:<br />
&lt;input type=“number” ng-model=“curinr” /&gt;<br />
&lt;br /&gt;<br />
Currency in Dollar: {{curinr*62.27}}<br />
&lt;br /&gt;<br />
&lt;b&gt;nd-repeat&lt;/b&gt;&lt;br /&gt;<br />
&lt;div ng-init=“myFavoriteWebsites=[‘http://www.c-sharpcorner.com/’,’http://www.codeproject.com/’,’http://sibeeshpassion.com/’]”&gt;<br />
&lt;ul&gt;<br />
My favorite websites are:<br />
&lt;li ng-repeat=“n in myFavoriteWebsites”&gt;{{n}}<br />
&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;/div&gt;<br />
&lt;b&gt;ng-Controller&lt;/b&gt;&lt;br /&gt;<br />
&lt;div &gt;<br />
Currency in INR:<br />
&lt;input type=“number” ng-model=“inrvalue” /&gt;<br />
&lt;br /&gt;<br />
Currency in Dollar: {{inrToDollar()}}<br />
&lt;/div&gt;<br />
&lt;br /&gt;<br />
&lt;/div&gt;<br />
&lt;script src=“~/Script/angular.min.js”&gt;&lt;/script&gt;<br />
&lt;script&gt;<br />
var my = angular.module(‘angularBasic’, []);<br />
my.controller(‘InrToDollar’, function ($scope) {<br />
$scope.inrToDollar = function () {<br />
return $scope.inrvalue * 62.27;<br />
}<br />
});<br />
&lt;/script&gt;<br />
[/html]</p>
<h3>Conclusion</h3>
<p>Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<h3>Your turn. What do you think?</h3>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/basics-of-angularjs/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
			</item>
	</channel>
</rss>
