2016年12月20日 星期二

[MEAN] Tutorial

https://thinkster.io/tutorials/mean-stack/creating-schemas-with-mongoose

Self-study notes:

what is state ?

.state
@ AngularApp.js
define the url -> controller -> view.html relationship
define "otherwise" page redirection

.controller
@ AngularApp.js

where is view ?

place <ui-view></ui-view> into index.ejs
- to tell ui-router where to place the javascript-triggered template view


what is factory ?

kind of an Angular service
return common object for different controllers
can keep data for an application lifetime
main logics should go here than in controllers

what is data-binding ?

to allow showing synchronised model data into view at all time
- AngularJS will be responsible for this

what is special with $scope ?

- note for the special dollar sign
- bridge between AngularJS controller and view 
- can bind with functions or variables
- {{hhhhheelllooooo}} as notation in view

Any difference between .config and .run ?

Config block > service > injector > run block

Structure of an AngularJS app:


- defines config, which defines routes
- defines controllers
- defines factories, blablabla ...


Why there is a $ sign for some variables?

AngularJS will inject these special-defined variables into the functions

A look as sample on my "sticker" function:




Reference

https://tylermcginnis.com/angularjs-factory-vs-service-vs-provider/

沒有留言:

張貼留言

Weight Loss! The journey continues

是一個漫長的奮鬥旅程…… 最近嘗試努力改變的生活習慣: 晚上九時半去瞓覺 瞓覺前唔用電子奶咀,即喺ipad同手提電話(因為呢家部電話用耐咗,會無電要叉過夜) 用蔬果代替日常零食,例子有:車厘茄、藍莓、士多啤梨、粟米芯、提子,都係細細地嘅一舊一舊comp食啲 唔食熱氣零食 安靜去每...