|
1 | 1 | (function(){ |
2 | 2 | "use strict"; |
3 | 3 | angular.module("app",[ |
4 | | - "price" |
| 4 | + "price", |
| 5 | + "toHtml", |
| 6 | + "myComponent", |
| 7 | + "ScrollService", |
| 8 | + "scrollToTop" |
5 | 9 | ]).run(function($templateCach){ |
6 | | - $templateCach.put('myTamplate.html','This is the<br/>'); |
| 10 | + $templateCach.put('myTamplate.html','This is the<br/> contant of'); |
7 | 11 | }); |
8 | 12 | })(); |
9 | 13 |
|
|
24 | 28 | "use strict"; |
25 | 29 | angular.module("toHtml",[]) |
26 | 30 | .filter("toHtml",toHtml); |
| 31 | + |
27 | 32 | toHtml.$inject=["$sce"]; |
28 | 33 |
|
29 | 34 | function toHtml($sce){ |
|
37 | 42 | "use strict"; |
38 | 43 | angular.module("app") |
39 | 44 | .controller("myCtrl",myCtrl); |
40 | | - myCtrl.$inject=["$scope","$filter","$http","$q","$sce","$templateCache","$interval"]; |
41 | | - function myCtrl($scope,$filter,$http,$q,$sce,$templateCache,$interval){ |
| 45 | + myCtrl.$inject=["$scope","$filter","$http","$q","$sce","$templateCache","$interval","testConstant","testConstant2","massage","massages","ScrollService"]; |
| 46 | + function myCtrl($scope,$filter,$http,$q,$sce,$templateCache,$interval,testConstant,testConstant2,massage,massages){ |
42 | 47 | var myCtrl=this; |
43 | 48 | myCtrl.price=$filter("price")(25,"#"); |
44 | 49 | myCtrl.serverData={}; |
|
52 | 57 | myCtrl.selectedOption=""; |
53 | 58 | myCtrl.imageSrc=""; |
54 | 59 |
|
55 | | - myCtrl.options={ |
56 | | - {value:"",lable:"Select item"}, |
57 | | - {value:"item1",lable:"Select item1"}, |
58 | | - {value:"item2",lable:"Select item2"}, |
59 | | - {value:"item3",lable:"Select item3"}, |
60 | | - {value:"item4",lable:"Select item4"}, |
61 | | - {value:"item5",lable:"Select item5"}, |
62 | | - {value:"item6",lable:"Select item6"}, |
| 60 | + console.log(testConstant); |
| 61 | + console.log(testConstant2); |
| 62 | + |
| 63 | + myCtrl.options=[ |
| 64 | + {value:"",label:"Select item"}, |
| 65 | + {value:"item1",label:"Item1 label"}, |
| 66 | + {value:"item2",label:"Item2 label"}, |
| 67 | + {value:"item3",label:"Item3 label"}, |
| 68 | + {value:"item4",label:"Item4 label"}, |
| 69 | + {value:"item5",label:"Item5 label"}, |
| 70 | + {value:"item6",label:"Item6 label"}, |
63 | 71 |
|
64 | | - } |
| 72 | + ] |
65 | 73 |
|
66 | 74 | myCtrl.onBlur=onBlur; |
67 | 75 | myCtrl.askUser=askUser; |
68 | 76 | myCtrl.usersFilterMethod=usersFilterMethod; |
| 77 | + myCtrl.getMassage=getMassage; |
| 78 | + myCtrl.getMassagesCount=getMassagesCount; |
| 79 | + |
| 80 | + function getMassage(){ |
| 81 | + return massages.massage; |
| 82 | + } |
| 83 | + |
| 84 | + function getMassagesCount(){ |
| 85 | + return massages.list.length; |
| 86 | + } |
69 | 87 |
|
70 | 88 | function onBlur($event){ |
71 | 89 | console.log($event); |
|
110 | 128 |
|
111 | 129 | })(); |
112 | 130 |
|
| 131 | +(function (){ |
| 132 | + "use strict"; |
| 133 | + |
| 134 | + angular.module("app") |
| 135 | + .constant("testConstant","testConstantValue") |
| 136 | + .constant("testConstant2",{ |
| 137 | + "key1":"value1", |
| 138 | + "key2":"value2" |
| 139 | + }) |
| 140 | +})(); |
| 141 | + |
| 142 | +(function(){ |
| 143 | + angular.module("app") |
| 144 | + .value("massage","") |
| 145 | + .value("massages",{ |
| 146 | + list:[] |
| 147 | + }) |
| 148 | +})(); |
| 149 | + |
| 150 | +(function(){ |
| 151 | + "use strict"; |
| 152 | + |
| 153 | + angular.module("app") |
| 154 | + .controller("massagesController",massagesController); |
| 155 | + |
| 156 | + massagesController.$inject=["massage","massages","ScrollService"]; |
| 157 | + function massagesController(massage,massages,ScrollService){ |
| 158 | + var massagesController=this; |
| 159 | + |
| 160 | + massagesController.massageField=""; |
| 161 | + |
| 162 | + massagesController.sendMassage=sendMassage; |
| 163 | + |
| 164 | + function sendMassage(newMassage){ |
| 165 | + massage.list.push(newMassage); |
| 166 | + massages.massage=newMassage; |
| 167 | + } |
| 168 | + } |
| 169 | +})(); |
| 170 | + |
| 171 | +(function(){ |
| 172 | +"use strict"; |
| 173 | + |
| 174 | + angular.module("ScrollService",[]) |
| 175 | + .service("ScrollService",ScrollService); |
| 176 | + |
| 177 | + ScrollService.$inject=["testFactory"]; |
| 178 | + function ScrollService(testFactory){ |
| 179 | + return{ |
| 180 | + scrollTop:scrollTop |
| 181 | + } |
| 182 | + |
| 183 | + function scrollTop(position){ |
| 184 | + console.log(testFactory); |
| 185 | + testFactory.method(); |
| 186 | + $("body").animate({"scrollTop":position},500); |
| 187 | + } |
| 188 | + } |
| 189 | + |
| 190 | + |
| 191 | +})(); |
| 192 | + |
| 193 | +(function(){ |
| 194 | + "use strict"; |
| 195 | + angular.module("app") |
| 196 | + .factory("testFactory",testFactory); |
| 197 | + |
| 198 | + function testFactory(){ |
| 199 | + return{ |
| 200 | + key1:"value1", |
| 201 | + key2:"value2", |
| 202 | + obj:{"test":"rest"}, |
| 203 | + method:method |
| 204 | + } |
| 205 | + |
| 206 | + function scrollTop(position){ |
| 207 | + $("html,body").animate({"scrollTop":position},500); |
| 208 | + } |
| 209 | + } |
| 210 | + |
| 211 | +})(); |
| 212 | + |
| 213 | +(function(){ |
| 214 | + "use strict"; |
| 215 | + |
| 216 | + angular.module("app") |
| 217 | + .component("myMassanger",myMassanger()); |
| 218 | + |
| 219 | + function myMassanger(){ |
| 220 | + myMassangerCtrl.$inject=["massages"]; |
| 221 | + return{ |
| 222 | + templateUrl:"componentTemplate.html", |
| 223 | + //template:"<div><h1>{{myMassanger.myTitle}}</h1></div>", |
| 224 | + controller:myMassangerCtrl, |
| 225 | + controllerAs:"myMassanger", |
| 226 | + transclude:false, |
| 227 | + bindings:{ |
| 228 | + title:"@", |
| 229 | + onMassageSent:"&" |
| 230 | + } |
| 231 | + } |
| 232 | + |
| 233 | + function myMassangerCtrl(){ |
| 234 | + var myMassangerCtrl=this; |
| 235 | + |
| 236 | + myMassangerCtrl.massageField=""; |
| 237 | + |
| 238 | + myMassangerCtrl.sendMassage=sendMassage; |
| 239 | + |
| 240 | + function sendMassage(massage){ |
| 241 | + myMassangerCtrl.onMassageSent({"massage":massage}); |
| 242 | + massages.massage=massage; |
| 243 | + massages.list.push(massage); |
| 244 | + } |
| 245 | + } |
| 246 | + } |
| 247 | + |
| 248 | +})(); |
| 249 | + |
| 250 | + |
| 251 | +(function(){ |
| 252 | + "use strict"; |
| 253 | + |
| 254 | + angular.module("scrollToTop",["ScrollService"]) |
| 255 | + .directive("scrollToTop",scrollToTop); |
| 256 | + |
| 257 | + scrollToTop.$inject=["ScrollService"]; |
| 258 | + |
| 259 | + function scrollToTop(ScrollService){ |
| 260 | + return { |
| 261 | + restrict:"A", |
| 262 | + link:link |
| 263 | + //scope:false |
| 264 | + } |
| 265 | + function link($scope,$element){ |
| 266 | + $element.on("click",function(){ |
| 267 | + ScrollService.scrollToTop(0); |
| 268 | + }) |
| 269 | + |
| 270 | + } |
| 271 | + } |
| 272 | + |
| 273 | + |
| 274 | +})(); |
| 275 | + |
| 276 | + |
| 277 | +(function(){ |
| 278 | + "use strict"; |
| 279 | + |
| 280 | + angular.module("app") |
| 281 | + .factory("myInterceptors",myInterceptors); |
| 282 | + .config("$httpProvider",interceptorsConfig); |
| 283 | + |
| 284 | + myInterceptors.$inject=["$q"]; |
| 285 | + function myInterceptors($q){ |
| 286 | + return{ |
| 287 | + request:function(config){ |
| 288 | + console.log(config); |
| 289 | + return config; |
| 290 | + }, |
| 291 | + response:function(response){ |
| 292 | + return response; |
| 293 | + }, |
| 294 | + requestError:function(rejectReason){ |
| 295 | + return $q.reject(rejectReason); |
| 296 | + }, |
| 297 | + responseError:function(response){ |
| 298 | + return $q.reject(response); |
| 299 | + } |
| 300 | + } |
| 301 | + } |
| 302 | + |
| 303 | + interceptorsConfig.$inject=["$httpProvider"]; |
| 304 | + function interceptorsConfig($httpProvider){ |
| 305 | + $httpProvider.interceptors.push('myInterceptors'); |
| 306 | + } |
| 307 | + |
| 308 | +})(); |
| 309 | + |
| 310 | + |
| 311 | + |
| 312 | + |
| 313 | + |
| 314 | + |
| 315 | + |
| 316 | + |
113 | 317 |
|
114 | 318 |
|
115 | 319 |
|
|
0 commit comments