�x���¹�������ֱ�ӳ���
�gӭ���R�ЈD�W(w��ng) Ո | ע��
> >>
Angular JS��(qu��n)���̳�-���w���°汾1.2.x

���] Angular JS��(qu��n)���̳�-���w���°汾1.2.x

���ߣ��ռ{
�����磺�����]늳���������r�g��2014-08-01
�_���� 16�_ 퓔�(sh��)�� 456
�� �D �r:¥49.5(5.0��) ���r  ¥99.0 ��䛺�ɿ������T�r
����ُ��܇ �ղ�
�_������ ȫ�����]
?�½������س���
������Ǖ�����>
�I�^����Ʒ����߀�I��

Angular JS��(qu��n)���̳�-���w���°汾1.2.x ���(qu��n)��Ϣ

Angular JS��(qu��n)���̳�-���w���°汾1.2.x ������ɫ

��angularjs��(qu��n)���̡̳��njW��angularjs�Ĺ��J��(j��ng)������(n��i)��ȫ�����v��ͨ�����m�ϸ��ӴεČW���ߡ����ߓ����S����angularjs�_�l(f��)�ͽ̌W��(j��ng)���Ҳ��һλȫ�����̎���ȫ��35�����ɜ\������v����angularjs�Ļ�������ͻ������ܣ�����ģ�K���������������������_ʽ��ָ����·������هע��ȣ���Ҫ���Ǖ��Ќ�ÿһ��������v�ⶼ�����ǡ����ֵ�ʾ���ʹ��a��׌�x��ͨ�^���֌��`�������w�����@Щ����ĺ��x�̓rֵ����angularjs��(qu��n)���̡̳���벿�����뵽angularjs�����_�l(f��)��ϵ�y(t��ng)��ӑՓ�˷���(w��)��ͨ�����¼����ܘ�(g��u)���Ӯ������ػ�����ȫ���������Ƅӑ��õ����}�� ������angularjs��(qu��n)���̡̳��m�ϸ����Ӵε�angularjs�_�l(f��)�ˆT�W�����oՓ�dz��ڹ�����Ҫ��߀�Ǻ����ĵ��(q��)ʹ��ֻҪ����ص�����angularjs����angularjs��(qu��n)���̡̳�����׌��M�d���w��

Angular JS��(qu��n)���̳�-���w���°汾1.2.x ��(n��i)�ݺ���

angularjs��google�_�l(f��)����һ���a(ch��n)�I(y��)��web���ÿ����*��l(f��)����2009�����S��ȫ�򱊶�web�Ŀ������spa������퓑��ã��ĸ��������angularjs�M���˳��췀(w��n)�������njW�����о���һ��web�_�l(f��)�����x��ܡ�

�f���W��angularjs�����������х������ϾW(w��ng)���������m(x��)��x�ĵ�Ч��ʽ���������Qangularjs�I(l��ng)�����̱�ʽ�����������ஔ?sh��)�ƪ�����w���P(gu��n)��angularjs�Ď׺����Ѓ�(n��i)��������һ����(qu��n)���̳�������һ������ָ�������ڛ]�н�(j��ng)����������ƽ����ͨ�׵��v�����f�M�����ܵĽM��������׌�˺��o�����ص������ң�Ѹ���I(l��ng)����һ��web�����_�l(f��)�ľ���������������P(gu��n)��(j��ng)򞣬�DZ�����angularjs����ͼ��g(sh��)����(ji��)��ȫ���������Լ�������١����п�����v������������ص������@����ܣ����Լ�š�I(y��)���g(sh��)�ޟ�֮·�ϸ��Mһ����

�������Y��ȫ�����̎��Ĵ������������ɓ����S����(j��ng)�ć���(n��i)angularjs���g(sh��)���҈�(zh��)�P���g��ͨ���׶���ȫ���������njW��angularjs�����e�^�Ľ�(j��ng)��֮�����oՓ�dz��ڹ�����Ҫ��߀�Ǻ����ĵ��(q��)ʹ��ֻҪ����ص�����angularjs����������׌��е��M����

���������wangularjs�����¸�����

�p��(sh��)��(j��)����
��هע��
������
������
·��
�͑���ģ��
����(w��)
ͨ�^xhr���F(xi��n)�ӑB(t��i)��(n��i)��
�yԇ
�^�V��
���Ʊ����C
��Ȝyԇ
����ָ��
���I(y��)����
��ie��֧��

Angular JS��(qu��n)���̳�-���w���°汾1.2.x Ŀ�

Ŀ���



��1�¡����Rangularjs��1

1.1���g�[����Ϋ@ȡ�W(w��ng)퓡�1

1.2���g�[����ʲô��2

1.3��angularjs��ʲô��2

1.3.1��angularjs��ʲô��ͬ��3

1.3.2���S�ɡ�3



��2�¡���(sh��)��(j��)������**��angularjs web���á�4

2.1��angularjs�еĔ�(sh��)��(j��)������5

2.2�����εĔ�(sh��)��(j��)������6

2.3����(sh��)��(j��)������*�ь��`��8



��3�¡�ģ�K��10

3.1������(sh��)��11

3.1.1��name(�ַ���)��11

3.1.2��requires(�ַ�����(sh��)�M)��11



��4�¡�������12

4.1��ҕ�D��$scope�����硡12

4.2������html���ѡ�13

4.3������������ʲô��14

4.4��$scope���������ڡ�14

4.4.1����(chu��ng)����15

4.4.2��朽ӡ�15

4.4.3�����¡�15

4.4.4���N����15

4.5��ָ���������15



��5�¡���������16

5.1��������Ƕ��(���������������)��18



��6�¡����_ʽ��20

6.1������angularjs���_ʽ��20

6.2����ֵ�ַ�����21



��7�¡��^�V����24

7.1���Զ��x�^�V����29

7.2�������C��29



��8�¡�ָ��顡43

8.1��ָ��Զ��xhtmlԪ�غ͌��ԡ�44

8.2����ָ���Ђ��f��(sh��)��(j��)��50



��9�¡���(n��i)��ָ�56

9.1�����A(ch��)ng����ָ�56

9.1.1���������ԡ�56

9.1.2��������ԡ�58

9.2����ָ����ʹ����������59



��10�¡�ָ��Ԕ�⡡72

10.1��ָ��x��72

10.1.1��restrict(�ַ���)��74

10.1.2����(y��u)�ȼ�(��(sh��)ֵ��)��75

10.1.3��terminal(������)��75

10.1.4��template(�ַ����򺯔�(sh��))��76

10.1.5��templateurl(�ַ����򺯔�(sh��))��76

10.1.6��replace(������)��77

10.2��ָ��������77

10.2.1��scope����(sh��)(�����ͻ�?q��)��?��78

10.2.2�����x������80

10.3���������ԡ�81

10.3.1��transclude��82

10.3.2��controller(�ַ����򺯔�(sh��))��84

10.3.3��controlleras(�ַ���)��86

10.3.4��require(�ַ�����(sh��)�M)��86

10.4��angularjs���������ڡ�87

10.4.1�����g�A��87

10.4.2��compile(����򺯔�(sh��))��88

10.4.3��朽ӡ�89

10.5��ngmodel��90

10.5.1���Զ��x��Ⱦ��92

10.5.2�����ԡ�92

10.6���Զ��x��C��93



��11�¡�angularjsģ�K���d��95

11.1�����á�95

11.2���\�ЉK��96



��12�¡�����ҕ�D��·�ɡ�98

12.1�����b��98

12.2������ģ�塡99

12.3��·�ɡ�99

12.4��$location����(w��)��103

12.5��·��ģʽ��105

12.5.1��html5ģʽ��105

12.5.2��·���¼���106

12.5.3���P(gu��n)����������������107

12.6�������P(gu��n)��·�ɵă�(n��i)�ݡ�107

12.6.1��������¼��d��107

12.6.2�������ĵ�ַ׃����107



��13�¡���هע�롡108

13.1���Ɣ�ʽע��•����109

13.2���@ʽע��•����110

13.3���Ѓ�(n��i)ע��•����110

13.4��$injector api��111

13.4.1��annotate()��111

13.4.2��get()��111

13.4.3��has()��111

13.4.4��instantiate()��112

13.4.5��invoke()��112

13.5��ngmin��112

13.5.1�����b��113

13.5.2��ʹ��ngmin��113

13.5.3������ԭ����113



��14�¡�����(w��)��114

14.1��ע��һ������(w��)��114

14.2��ʹ�÷���(w��)��116

14.3����(chu��ng)������(w��)�r���O(sh��)��헡�118

14.3.1��factory()��119

14.3.2��service()��119

14.3.3��provider()��120

14.3.4��constant()��122

14.3.5��value()��122

14.3.6���Εrʹ��value()��constant()��123

14.3.7��decorator()��123



��15�¡�ͬ���ͨ�ţ�xhr�ͷ���(w��)��ͨ�š�125

15.1��ʹ��$http��125

15.2���O(sh��)����128

15.3��푑�����130

15.4������httpՈ��131

15.5���r������132

15.6���O(sh��)��$httpprovider��133

15.7��ʹ��$resource��134

15.8�����b��134

15.9������$resource��135

15.9.1������http get������135

15.9.2�����ڷ�http get��͵ķ�����136

15.9.3��$resource������137

15.9.4��$resource�����Ǯ����ġ�138

15.9.5�����ӌ��ԡ�138

15.10���Զ��x$resource������138

15.11��$resource�O(sh��)����139

15.12��$resource����(w��)��141

15.13��ʹ��restangular��142

15.14��restangular���顡142

15.15�����brestangular��143

15.16��restangular���󺆽顡144

15.17��ʹ��restangular��145

15.17.1���ҵ�http��������ô�k��146

15.17.2���Զ��x��ԃ����(sh��)���^��147

15.18���O(sh��)��restangular��147



��16�¡�xhr���`��153

16.1�������ͬԴ���ԡ�153

16.2��jsonp��153

16.3��ʹ��cors��154

16.3.1���O(sh��)�á�154

16.3.2������(w��)����cors֧�֡�155

16.3.3������Ո��155

16.3.4���Ǻ���Ո��156

16.4������(w��)���˴�����157

16.5��ʹ��json��157

16.6��ʹ��xml��158

16.7��ʹ��angularjs�M��������C��159

16.7.1������(w��)��������159

16.7.2���͑���������C��160

16.8����mongodbͨ�š�165



��17�¡�promise��168

17.1��ʲô��promise��168

17.2����ʲôʹ��promise��169

17.3��angular�е�promise��170

17.4���ʽՈ��173

17.4.1��all(promises)��174

17.4.2��defer()��174

17.4.3��reject(reason)��174

17.4.4��when(value)��174



��18�¡�����(w��)��ͨ�š�175

18.1���Զ��x����(w��)���ˡ�175

18.2�����bnodejs��175

18.3�����bexpress��176

18.4���{(di��o)��api��178

18.5��ʹ��amazon aws�ğo����(w��)�����á�181

18.5.1��dynamodb��181

18.5.2������֪ͨ����(w��)(sns)��181

18.5.3����������(w��)(sqs��simple queue service)��182

18.5.4�����δ惦����(w��)(s3)��182

18.5.5����ȫ���Ʒ���(w��)(sts)��182

18.6��awsjs + angular��182

18.7���_ʼ��182

18.8����B��184

18.9�����b��184

18.10���\��185

18.11�����J�C/�b��(qu��n)��186

18.12��userservice��190

18.13���w�Ƶ�aws�ϡ�191

18.14��awsservice��194

18.15����dynamo���_ʼ��196

18.16��$cachefactory��196

18.17������currentuser��197

18.18����s3��199

18.19��̎���ļ��ς���201

18.20����ԃdynamo��203

18.21����html�@ʾ�б���204

18.22�������҂�����Ʒ��205

18.23��ʹ��stripe��206

18.24��ʹ��firebase�ğo����(w��)�����á�209

18.25��ʹ��firebase��angular��������(sh��)��(j��)������210

18.26����angularfire�_ʼ��211

18.26.1��ע�Բ���(chu��ng)��һ��firebase��211

18.26.2������firebase��angularfire�졡212

18.26.3����firebase������ه����ӡ�212

18.26.4������ģ�͵�firebase url��212

18.26.5����(sh��)��(j��)ͬ����213

18.27����angularfire������214

18.28��firebase�¼���215

18.29���@ʽͬ����215

18.30����angularfire�M���J�C��216

18.31���J�C�¼���217

18.31.1��$logout()��218

18.31.2��$createuser()��218

18.32��ʹ��firebase�йܲ������angular���á�218

18.32.1�����bfirebase���ߡ�218

18.32.2���������webվ�c��219

18.33������angularfire֮�⡡219



��19�¡��yԇ��220

19.1����ʲôҪ���yԇ��220

19.2���yԇ���ԡ�220

19.3���_ʼ�yԇ��220

19.4��angularjs�yԇ����͡�221

19.4.1����Ԫ�yԇ��221

19.4.2���˵��˜yԇ��222

19.5���_ʼ��222

19.6����ʼ��karma�����ļ���223

19.7�������x헡�226

19.8��ʹ��requirejs��231

19.9��jasmine��233

19.9.1�����t�׼���233

19.9.2�����xһ�����t��233

19.10���A�ڡ�234

19.10.1����(n��i)�õ�ƥ������234

19.10.2�����b��ж�d��237

19.11���˵��˵Ľ�B��238

19.11.1���x�ݔ�롡244

19.11.2���؏�ѭ�h(hu��n)Ԫ�ء�244

19.12��ģ�M�͜yԇ��������(sh��)��245

19.13��ģ�M$httpbackend��246

19.14���yԇһ�����á�251

19.14.1���yԇ·�ɡ�252

19.14.2���yԇ����(n��i)�ݡ�255

19.14.3���yԇ��������257

19.14.4���yԇ����(w��)�͹��S��259

19.14.5���yԇ�^�V����263

19.14.6���yԇģ�塡264

19.14.7���yԇָ�266

19.15���yԇ�¼���269

19.16����angular�ij��m(x��)���ɡ�270

19.17��protractor��270

19.18�����á�272

19.19�������x헡�273

19.20�������yԇ��275

19.21���yԇ���`��278

19.21.1���҂��đ��á�278

19.21.2���yԇ�IJ��ԡ�279

19.22�������҂���**���yԇ��279

19.23���yԇݔ���281

19.23.1���yԇ�б���282

19.23.2���yԇ·�ɡ�284

19.24����挦��285



��20�¡��¼���287

20.1��ʲô���¼���287

20.2���¼�������287

20.2.1��ʹ��$emit��ð���¼���288

20.2.2��ʹ��$broadcast���‚��f�¼���288

20.3���¼��O(ji��n) ��289

20.4���¼�����289

20.5���¼����P(gu��n)�ĺ��ķ���(w��)��290

20.5.1������ϵ�y(t��ng)��$emitted�¼���290

20.5.2������ϵ�y(t��ng)��$broadcast�¼���290



��21�¡��ܘ�(g��u)��292

21.1��Ŀ䛽Y(ji��)��(g��u)��292

21.2��ģ�K��293

21.3����������294

21.4��ָ�296

21.5���yԇ��296



��22�¡�angular�Ӯ���297

22.1�����b��297

22.2����������\���ġ�297

22.3��ʹ��css3�^�ɡ�298

22.4��ʹ��css3�Ӯ���300

22.5�����ecss�^��/�Ӯ���301

22.5.1�����ecss�^�ɡ�301

22.5.2�����ecss�Ӯ���302

22.5.3��ʲôָ��֧�ֽ��e�Ӯ���302

22.6��ʹ��javascript�Ӯ���302

22.7��΢�{(di��o)�Ӯ���303

22.8��dom���{(di��o)�¼���304

22.9����(n��i)��ָ��ĄӮ���304

22.9.1��ngrepeat�Ӯ���304

22.9.2��ngview�Ӯ���306

22.9.3��nginclude�Ӯ���308

22.9.4��ngswitch�Ӯ���310

22.9.5��ngif�Ӯ���312

22.9.6��ngclass�Ӯ���314

22.9.7��ngshow/nghide�Ӯ���316

22.10����(chu��ng)���Զ��x�Ӯ���318

22.10.1��addclass()��319

22.10.2��removeclass()��320

22.10.3��enter()��321

22.10.4��leave()��322

22.10.5��move()��323

22.11���c�������켯�ɡ�324

22.11.1��animate.css��324

22.11.2��tweenmax/tweenlite��324



��23�¡�digestѭ�h(hu��n)��$apply��326

23.1��$watch���326

23.2���Kֵ�z�顡327

23.3��$watch��328

23.4��$watchcollection��330

23.5������е�$digestѭ�h(hu��n)��330

23.6��$evalasync���331

23.7��$apply��332

23.8���Εrʹ��$apply��332



��24�¡�����angular��334

24.1��ҕ�D�Ĺ���ԭ����335

24.1.1�����g�A��335

24.1.2���\�Еr��336



��25�¡�angularjs���A�Uչ��337

25.1��angularui��337

25.2�����b��337

25.3��ui-router��337

25.3.1�����b��337

25.3.2���¼���342

25.3.3��$stateparams��343

25.3.4��$urlrouterprovider��344

25.3.5����(chu��ng)��һ����������345

25.4��ui-utils��346

25.4.1�����b��347

25.4.2��mask��347

25.4.3��ui-event��347

25.4.4��ui-format��348



��26�¡��Ƅӑ��á�350

26.1��푑�ʽweb���á�350

26.2��������350

26.2.1�����b��350

26.2.2��ngtouch��351

26.2.3��$swipe����(w��)��352

26.2.4��angular-gestures�Ͷ��c�|���քݡ�353

26.2.5�����bangular-gestures��354

26.2.6��ʹ��angular-gestures��354

26.3��cordova�е�ԭ�����ó���355

26.4��cordova���T��356

26.4.1��cordova�_�l(f��)���̡�359

26.4.2��ƽ�_��359

26.4.3�������359

26.4.4����(g��u)����360

26.4.5��ģ�M���\�С�360

26.4.6���_�l(f��)�A��360

26.4.7��anguar�е�cordova����(w��)��361

26.5������angular��362

26.6��ʹ��yeoman��(g��u)����363

26.6.1���޸�yeoman�Ա�ʹ��cordova��364

26.6.2���b��yeoman��(g��u)����365

26.6.3����(g��u)���ƄӲ��֡�365

26.6.4��̎����������367



��27�¡����ػ���369

27.1��angular-translate��369

27.2�����b��369

27.3������đ���һ�N���Z�ԡ�370

27.4�����Z��֧�֡�371

27.5���\�Еr�ГQ�Z�ԡ�372

27.6�����d�Z�ԡ�373

27.7��angular-gettext��374

27.8�����b��374

27.9���÷���375

27.10���ַ�����ȡ��375

27.11�����g�ַ�����377

27.12�����g���Z�ԡ�378

27.13����׃�Z�ԡ�379



��28�¡����桡381

28.1��ʲô�Ǿ��桡381

28.2��angular�еľ��桡381

28.2.1��$cachefactory���顡381

28.2.2�����挦��382

28.3��$http�еľ��桡382

28.3.1��Ĭ�J��$http���桡382

28.3.2���Զ��x���桡383

28.4����$http�O(sh��)��Ĭ�J���桡384



��29�¡���ȫ�ԡ�385

29.1��������������D(zhu��n)�x��$sce����(w��)��385

29.2��url������387

29.3��url������388

29.4��$sce api��388

29.4.1��gettrusted��388

29.4.2��parse��389

29.4.3��trustas��389

29.4.4��isenabled��390

29.5������$sce��390

29.6������ه����������͡�390



��30�¡�angularjs��ie�g�[����391

30.1��ajax���桡393

30.2��angularjs�е�seo��393

30.3��ʹangular���ÿɱ�������393

30.4������(w��)�ˡ�393

30.4.1��hashbang�Z����394

30.4.2��html5·��ģʽ��394

30.5������(w��)��̎��seo���x헡�394

30.5.1��ʹ��node/express���g����395

30.5.2��ʹ��apache�،�url��395

30.5.3��ʹ��ngnix����url��396

30.6���@ȡ���ա�396

30.7��ʹ��zombie.js�@ȡhtml���ա�397

30.8��ʹ��grunt-html-snapshot��398

30.9��prerender.io��399

30.10��
չ�_ȫ��

Angular JS��(qu��n)���̳�-���w���°汾1.2.x ���P(gu��n)�Y��

���ڴ�֮ǰ���Ҟ��ˌW��angularjs�����ھW(w��ng)��������x�e�ˌ��IJ��������^�X��ʼ�K�]������һ������^���@������(n��i)����ĺ�ȫ��ȫ�����ҽM���î����v��ͨ�ף�׌�Ҍ�angularjs����ȫ��ϵ�y(t��ng)����������

���ҿ��^�Îױ�angularjs�D������ֻ�б���ȫ����Ԕ�M��ѭѭ���T��ͨ���׶��������κ�һ�����o���c���ȼ�����

�� �@Ȼ������ari lerner���H��һλ׿Խ��ܛ�����̎�������߀��һλ��ŵ��ώ�������������angularjs�ĸ��N�����v��һ�������ܶ����ĸ���v��͸���׶�����
�������R�d�x���uՓ

Angular JS��(qu��n)���̳�-���w���°汾1.2.x ���ߺ���

Ari Lerner ȫ�����̎������ж���AngularJS��(j��ng)򞣬���k���\�IAngularJS��ӈ�ng-newsletter.com����������ȹ��̎���Ӗ�WУHack Reactor����AngularJS�v�������Ĺ����漰ܛ���_�l(f��)�ĸ����ӴΣ��������A(ch��)�O(sh��)ʩ�_�l(f��)��ǰ�ˑ����_�l(f��)�����܃�(y��u)������Ŀǰס���f��ɽһ��ꖹ����ĵĵط���߀��FullStack.io��(chu��ng)ʼ�ˡ�

��Ʒ�uՓ(0�l)
���o�uՓ����
�������]
����픲�
�ЈD�W(w��ng)
�ھ��ͷ�