@@ -316,55 +316,57 @@ angular.module('homepage', ['ngAnimate', 'ui.bootstrap', 'download-data'])
316
316
} ,
317
317
controllerAs : 'plnkr' ,
318
318
controller : function ( ) {
319
- var ctrl = this ;
320
319
321
- var name = '' ,
322
- bootstrapStylesheet = 'http://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/css/bootstrap-combined.min.css' ,
323
- plnkrFiles = [ ] ;
320
+ this . $onInit = function ( ) {
321
+ var ctrl = this ;
324
322
325
- angular . forEach ( ctrl . files . split ( ' ' ) , function ( filename , index ) {
326
- var content ;
323
+ var name = '' ,
324
+ bootstrapStylesheet = 'http://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/css/bootstrap-combined.min.css' ,
325
+ plnkrFiles = [ ] ;
327
326
328
- if ( index === 0 ) {
329
- var head = templateBuilder . createLocalDependencies ( ctrl . files ) ;
327
+ angular . forEach ( ctrl . files . split ( ' ' ) , function ( filename , index ) {
328
+ var content ;
330
329
331
- head . push ( ' <link rel="stylesheet" href="' + bootstrapStylesheet + '">\n' ) ;
332
- content = templateBuilder . getIndexTemplate ( { resource : ctrl . resource , route : ctrl . route , firebase : ctrl . firebase } ) ;
333
- content = content .
334
- replace ( '__MODULE__' , ctrl . module ? '="' + ctrl . module + '"' : '' ) .
335
- replace ( '__HEAD__' , head . join ( '' ) ) .
336
- replace ( '__BODY__' , fetchCode ( filename , 4 ) ) ;
337
- } else {
338
- content = fetchCode ( filename ) ;
339
- }
330
+ if ( index === 0 ) {
331
+ var head = templateBuilder . createLocalDependencies ( ctrl . files ) ;
340
332
341
- content += templateBuilder . getCopyright ( filename ) ;
333
+ head . push ( ' <link rel="stylesheet" href="' + bootstrapStylesheet + '">\n' ) ;
334
+ content = templateBuilder . getIndexTemplate ( { resource : ctrl . resource , route : ctrl . route , firebase : ctrl . firebase } ) ;
335
+ content = content .
336
+ replace ( '__MODULE__' , ctrl . module ? '="' + ctrl . module + '"' : '' ) .
337
+ replace ( '__HEAD__' , head . join ( '' ) ) .
338
+ replace ( '__BODY__' , fetchCode ( filename , 4 ) ) ;
339
+ } else {
340
+ content = fetchCode ( filename ) ;
341
+ }
342
342
343
- plnkrFiles . push ( {
344
- name : index === 0 ? 'index.html' : filename , // plnkr expects an index.html
345
- content : content
343
+ content += templateBuilder . getCopyright ( filename ) ;
344
+
345
+ plnkrFiles . push ( {
346
+ name : index === 0 ? 'index.html' : filename , // plnkr expects an index.html
347
+ content : content
348
+ } ) ;
346
349
} ) ;
347
- } ) ;
348
350
349
- ctrl . open = function ( clickEvent ) {
351
+ ctrl . open = function ( clickEvent ) {
350
352
351
- var newWindow = clickEvent . ctrlKey || clickEvent . metaKey ;
353
+ var newWindow = clickEvent . ctrlKey || clickEvent . metaKey ;
352
354
353
- var postData = {
354
- 'tags[0]' : "angularjs" ,
355
- 'tags[1]' : "example" ,
356
- 'private' : true
357
- } ;
355
+ var postData = {
356
+ 'tags[0]' : "angularjs" ,
357
+ 'tags[1]' : "example" ,
358
+ 'private' : true
359
+ } ;
358
360
359
- angular . forEach ( plnkrFiles , function ( file ) {
360
- postData [ 'files[' + file . name + ']' ] = file . content ;
361
- } ) ;
361
+ angular . forEach ( plnkrFiles , function ( file ) {
362
+ postData [ 'files[' + file . name + ']' ] = file . content ;
363
+ } ) ;
362
364
363
- postData . description = 'AngularJS Example: ' + name ;
365
+ postData . description = 'AngularJS Example: ' + name ;
364
366
365
- formPostData ( 'http://plnkr.co/edit/?p=preview' , newWindow , postData ) ;
367
+ formPostData ( 'http://plnkr.co/edit/?p=preview' , newWindow , postData ) ;
368
+ } ;
366
369
} ;
367
-
368
370
}
369
371
} ;
370
372
} )
0 commit comments