Top Banner
AngularJs Warsztaty - stopień 1
38

Angular js warsztaty stopień 1

Jul 17, 2015

Download

Documents

Marcin Wosinek
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Angular js   warsztaty stopień 1

AngularJsWarsztaty - stopień 1

Page 2: Angular js   warsztaty stopień 1

AngularJs "Hello world"

● git checkout slide-1

Page 3: Angular js   warsztaty stopień 1

ng-include

● git checkout slide-2

Page 4: Angular js   warsztaty stopień 1

Kontroler

Page 5: Angular js   warsztaty stopień 1

$scope

Page 6: Angular js   warsztaty stopień 1

ng-controller

● git checkout slide-3● podpięcie kontrolera do częsci widoku● $scope działa tylko wewnątrz tagu na którym

jest kontroler

Page 7: Angular js   warsztaty stopień 1

Zadanie 1

● git checkout todo-1● dodanie kontrolera zawierajacego menu● dodanie i wyświetlenie menu w index.html

Page 8: Angular js   warsztaty stopień 1

Rozwiązanie 1

● git add .● git commit -m '(commit message)'● git checkout done-1

Page 9: Angular js   warsztaty stopień 1

$routeProvider

● git checkout slide-4

Page 10: Angular js   warsztaty stopień 1

ng-repeat<ul>

<li ng-repeat="project in projects">

<a href=""></a>:

</li>

</ul>

Page 11: Angular js   warsztaty stopień 1

Zadanie 2

● git checkout todo-2● zbudować menu zawierające linki do

wszystkich ścieżekvar object = {};

var array = [];

var arrayOfObjects = [

{

lorem: 1,

ipsum: 2

},{

test: 4

} ]

Page 12: Angular js   warsztaty stopień 1

Rozwiązanie 2

● git add .● git commit -m '(commit message)'● git checkout done-2

Page 13: Angular js   warsztaty stopień 1

Zadanie 3

● git checkout todo-3● zbudować własną podstronę, z

wyświetlaniem listy danych podanych w kontrolerze

Page 14: Angular js   warsztaty stopień 1

Rozwiązanie 3

● git add .● git commit -m '(commit message)'● git checkout done-3

Page 15: Angular js   warsztaty stopień 1

OrderBy

● git checkout slide-5<ul>

<li ng-repeat="product in products | orderBy:'price'">

</ul>

Page 16: Angular js   warsztaty stopień 1

Zadanie 4

● git checkout todo-4● wymień hardkodowany parametr na

pochodzący ze zmiennej ustawianej w formularzu

Page 17: Angular js   warsztaty stopień 1

Rozwiązanie 4

● git add .● git commit -m '(commit message)'● git checkout done-4

Page 18: Angular js   warsztaty stopień 1

filter

● git checkout slide-6● składnia filter: {experesion}<tr ng-repeat="person in list | orderBy:orderKey |

filter:'oo'">

Page 19: Angular js   warsztaty stopień 1

filter - argumenty

● 'Lorem ipsum'● {key: 'value'} ● {$: 'value'}

Page 20: Angular js   warsztaty stopień 1

Zadanie 5

● git checkout todo-5● zmienić filter na wyszukiwarkę z 3 polami:

szukanie po firstName, lastName lub wszędzie

Page 21: Angular js   warsztaty stopień 1

Rozwiązanie 5

● git add .● git commit -m '(commit message)'● git checkout done-5

Page 22: Angular js   warsztaty stopień 1

Funkcje w modelu<p>{{displayValueReturnedByFunction()}}</p>

<input ng-change="fireFunctionWhenChangeHappen()">

Page 23: Angular js   warsztaty stopień 1

Validowanie formularza

● git checkout slide-8

Page 24: Angular js   warsztaty stopień 1

Zadanie 6

● git checkout todo-6● newPerson form● ng-click

○ nazwaListy.push(nowyElement) ○ podstawić {}

Page 25: Angular js   warsztaty stopień 1

Rozwiązanie 6

● git add .● git commit -m '(commit message)'● git checkout done-6

Page 26: Angular js   warsztaty stopień 1

Trzymanie danych w controlerze

● git checkout slide-9● #/main

Page 27: Angular js   warsztaty stopień 1

Services

● git checkout slide-10● #/main

Page 28: Angular js   warsztaty stopień 1

Zadanie 7

● git checkout todo-7● dodanie własnego serwisu, People do

użytku przez ListCtrl

Page 29: Angular js   warsztaty stopień 1

Rozwiązanie 7

● git add .● git commit -m '(commit message)'● git checkout done-7

Page 30: Angular js   warsztaty stopień 1

Json - obiekt{

"about": "I'm an object",

"structure": {

"key": "value"

},

"arrays": [ "I", "can", "keep",

"them", "too" ]

}

Page 31: Angular js   warsztaty stopień 1

Json - tablica[

{

"objectId": 1

},

{

"objectId": 2

}

]

Page 32: Angular js   warsztaty stopień 1

Rest

● http://example.com/products● http://example.com/products/1

Page 33: Angular js   warsztaty stopień 1

$resource

● query()● get()

var userResource = $resource('/user/:userId', {});

userResource.get({userId: 1});

Page 34: Angular js   warsztaty stopień 1

Dane do json

● git checkout slide-11

Page 35: Angular js   warsztaty stopień 1

Podsumowanie

Page 36: Angular js   warsztaty stopień 1

Materiały

● http://docs.angularjs.org/tutorial/● http://egghead.io/

Page 37: Angular js   warsztaty stopień 1

Co dalej?

● webstorage etc.● backend● dev env● unit tests

Page 38: Angular js   warsztaty stopień 1

Stay tuned

● http://akai.org.pl/● http://poznan.gtug.pl/● http://www.meetup.com/Hacking-Poznan/