Git Product home page Git Product logo

angular_store's Introduction

Angular tutorial

functions as abstractions

Functions can be passed other functions. This allows for validation that a function is working a function can prevent another function of executing if there is a hazard

var work = function() {
  
  console.log("learning JS");
};

var dowork = function(f) {
  console.log("start work");
  
  try {
    f()
  }
  catch(ex){
    console.log(ex);
  }
  console.log("ended work");
};

dowork(work);

Using objects

var createWorker = function(){
  
  var workCount = 0;
  
  var task1 = function(){
    workCount += 1;
    console.log("task1 " + workCount);
  }
  var task2 = function(){
    workCount += 1;
    console.log("task2 " + workCount);
  }
  return {
    job1: task1,
    job2: task2
  }
}

var worker = createWorker();

worker.job1();
worker.job2();

Avoiding global variables

How can we prevent global variables from existing, wrap it all within a program

var program = funtion(){
  all code
}

or even better create an immediately invoked function

(function() {
  all code
}());

Controller basics

  • ng-controller, is a directive. we can place it inside a div like so
    var MainController = function($scope){ $scope.message = "hello"; };

Angular directives

ng-app -- ng-app='appname
ng-controller -- ng-controller='PotatoController as potato'
ng-class -- ng-class="{ active: tab.isSet(3) }"
ng-show -- ng-show='store.product.soldOut'
ng-hide -- ng-hide='store.product.available'
ng-repeat -- ng-repeat='element in bag.elementlist'
ng-src -- ng-src="{{ product.images[0].full }}" />
ng-click -- ng-click="tab.setTab(3)"

Angular filters

{{ data | filer:options }}

{{ '41235345324' | date:'mm/dd/yyyy' }}
{{ 'something' | uppercase}}
{{ 'Descriptions bla bla' | limitTo: 8 }}
ng-repeat="products in store.products | orderBy:'-price'">

angular_store

angular_store's People

Contributors

nrkfeller avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.