Skip to main content

Angular JS


 




Buil
 Built-in Directives









































ng-src :

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



ng-click :

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
























Solution :

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

(function() {
  var app = angular.module('gemStore', []);

  app.controller('StoreController', function(){
    this.products = gems;
  });

 app.controller('TabController', function(){
   this.tab = 1;
   this.setTab = function(ntab){
        this.tab = ntab;
   };
     this.isSet = function(ntab){
        return this.tab == ntab;
   };
  });




 app.controller('GalleryController',function(){
    this.current = 0;
    this.setCurrent = function(value) {
         this.current = value || 0;
      };

  });

     
     
>       
       
             






  • ng-repeat="image in product.images"

  • >           
             
           

         

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


    ng-model



                 
                 

    Submit a Review

                 
                   
                     
                   
                 
                 
                   
                 
                 
                    ng-model ="review.author"  type="email" class="form-control" placeholder="jimmyDean@example.org" title="Email" />
                 
                 
                   
                 
               


























        this.review = {};
        this.addReview = function(product){
        product.reviews.push(this.review);
        this.review = {};
        };
       
      });




    3.8 Form Validations 101



































    .ng-invalid.ng-dirty{
      border-color:red
    }
    .ng-valid.ng-dirty{
      border-color:green
    }


































































    ng -include 


    "'product-description.html'">

       



      app.directive("productReviews", function() {
        return {
          restrict: 'E',
          templateUrl: "product-reviews.html"
        };
      });

      app.directive("productSpecs",function(){
        return {
           restrict:'A',
           templateUrl:"product-specs.html"
        };
        

      });

    Controller 







        app.directive("productTabs",function(){
        return{
          restrict:'E',

          templateUrl:'product-tabs.html',
          controller: function() {
                this.tab = 1;
                this.isSet = function(checkTab) {
                   return this.tab === checkTab;
                 };
                this.setTab = function(setTab) {
                    this.tab = setTab;
                 };
            },
          controllerAs:'tab'
      };

        });





    =================================================================================


    5.1 Dependencies


    (function() {
      var app = angular.module("store-directives",[]);
      app.directive("productDescription", function() {
        return {
          restrict: 'E',
          templateUrl: "product-description.html"
        };
      });

      app.directive("productReviews", function() {
        return {
          restrict: 'E',
          templateUrl: "product-reviews.html"
        };
      });

      app.directive("productSpecs", function() {
        return {
          restrict:"A",
          templateUrl: "product-specs.html"
        };
      });

      app.directive("productTabs", function() {
        return {
          restrict: "E",
          templateUrl: "product-tabs.html",
          controller: function() {
            this.tab = 1;

            this.isSet = function(checkTab) {
              return this.tab === checkTab;
            };

            this.setTab = function(activeTab) {
              this.tab = activeTab;
            };
          },
          controllerAs: "tab"
        };
      });

      app.directive("productGallery", function() {
        return {
          restrict: "E",
          templateUrl: "product-gallery.html",
          controller: function() {
            this.current = 0;
            this.setCurrent = function(imageNumber){
              this.current = imageNumber || 0;
            };
          },
          controllerAs: "gallery"
        };
      });
      
    })();


    5.3 Services




















      app.controller('StoreController',['$http',function($http){
        var store = this;
        store.products = [];
        $http.get('/store-products.json').success(function(data){
          store.products = data;
        });

      }]);













    Angular JS is a structural framework for dynamic web apps





    It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly.

    AngularJS's data binding and dependency injection eliminate much of the code you would otherwise have to write.

     And it all happens within the browser, making it an ideal partner with any server technology.

    AngularJS teaches the browser new syntax through a construct we call directives. AngularJS is not a single piece in the overall puzzle of building the client-side of a web application.


    AngularJS is a client side MVC framework, which
    1.   provides a layer on top of jQuery.
    2. provides a framework and api to develop modular applications upon,
    3. üprovides well defined structure to your applications, where separation of concerns is well maintained.

    Each functionality of project belongs to a specific concern(data, view, business-logic), and thus reduces development time by several fold, maintenance and testability becomes a breeze with modular architecture. In AngularJS, you can achieve the same functionality in couple of lines of code, which with JQuery might take hundreds of lines. AngularJS takes care of all boilerplate code, and let you focus on core business logic, and look-n-feel of your application.



    There are 12 main constructs of angular js


    Template:  [HTML with additional mark up ]

    Directive:[ extend HTML with custom attributes and elments]


    Scope:[context that binds view with model]



    Expression:[access varibales & functions from scope]


    Filter:[formats the value of expression]

    Data binding :[sync data between model and view]

    Controller: the business logic behind the views


    Injector: Dependency injection container


    Module: container for different parts of application including

    •         Controller
    •         Services
    •         Filters
    •         Directives
    Which configures the injector

    ServiceReusable business logic independent views





    ONE WAY DATA BINDING

     ng-app>
        
            </span><span style="background-color: white;">Hello World</span><span style="background-color: white; color: rgb(0, 119, 0);">
        
    Name : type="text" ng-model="name" placeholder="Enter your name"/>

    Hello ng-bind="name">

    Hey {{name}}





    ng-app
    ng-controller
    ng-model
    ng -init

    BINDING ELEMENTS

    ng-bind
    ng-bind template
    ng-bind.HTML
    ng non bindable

    REPEAT ELEMENTS

    ng-repeat
    ng-repeatTrackByIndex


    EVENTS

     ng-show
    ng-hide,
    ng-disabled,
    ng-readonly,
    ng-click
    ng-db-click,
    ng-mouse[hover| click| up|down]
    ng- show|hide



    FILTERS

    Uppercase : The uppercase filter converts string to the uppercase.
    Lowercase : The lowercase filter convert string to the lowercase.
    Currency : The currency filter formats a number value to currency format.
    {{amount | currency : '$' : 3}}
    Dateformat:  {{todayDate | date:'short'}}
     {{todayDate | date:'medium'}}


    --> {{todayDate | date:'dd/MMM/yyyy'}}




    Comments

    Popular posts from this blog

    Microservices Design patterns

    What are microservices? Microservices - also known as the microservice architecture - is an architectural style that structures an application as a collection of services that are Highly maintainable and testable Loosely coupled Independently deployable Organized around business capabilities Owned by a small team The microservice architecture enables the rapid, frequent and reliable delivery of large, complex applications. It also enables an organization to evolve its technology stack. You are developing a server-side enterprise application. It must support a variety of different clients including desktop browsers, mobile browsers and native mobile applications. The application might also expose an API for 3rd parties to consume. It might also integrate with other applications via either web services or a message broker. The application handles requests (HTTP requests and messages) by executing business logic; accessing a database; exchanging messages with other systems; and returni...

    GraphQL

    What is GraphQL  API Standard invented & open-sourced by Facebook Alternative to  REST API  enables declarative data fetching  exposes single endpoint & responds to queries How it works?  Why Graphql? Improvises performance by reducing the data that is to be transferred over the internet Variety of different frontend frameworks and platforms on client-side Fast development speed & expectation for rapid feature development Why Graphql is better than REST? Flexibility & efficient  No more over /under fetching of data Over fetching : Under fetching: Insightful analytics  Schema serves as contract between client and server CORE CONCEPTS : SDL :SCHEMA DEFINITION LANGUAGE Writing Data with mutations 3 kinds of mutations creating new data updating existing data deleting existing data

    Jackson

    <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId> jackson-core </artifactId> <version>2.9.6</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId> jackson-annotations </artifactId> <version>2.9.6</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId> jackson-databind </artifactId> <version>2.9.6</version> </dependency> CBOR encoded data with Jackson <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-cbor</artifactId> <version>2.9.6</version> </dependency> In order to read and write MessagePack encoded data <dependency> <groupId>org.msgpack</groupId> <artifactId>jackson-dataformat-msgp...