Last active
August 29, 2015 14:02
-
-
Save Micka33/a8481c4acb4f229df21e to your computer and use it in GitHub Desktop.
Revisions
-
Micka33 revised this gist
Apr 29, 2015 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ (function(window, angular, undefined) {'use strict'; angular.module('loadRawData', []) .directive('rawData', ['$log', function($log) { return { restrict: 'A', link: function ($scope, $element, $attrs) @@ -13,9 +13,9 @@ if ($attrs.rawData.toLowerCase() == 'json') $scope[$attrs.ngBind] = angular.fromJson(text); }catch(e){ $log.error(e); $log.info('you sent:', text); $log.info('raw-data was expecting:', $attrs.rawData); } } } -
Micka33 revised this gist
Jun 20, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ more `if` can be added to be able to load strings/integers/booleans. ``` ... try{ if ($attrs.rawData.toLowerCase() == 'json') $scope[$attrs.ngBind] = angular.fromJson(text); ... ``` -
Micka33 revised this gist
Jun 20, 2014 . 2 changed files with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,14 +8,14 @@ So I want to embed the datas in my page on the first request to load them direct ``` <div> <p>{{the_datas}}</p> <script ng-bind='the_datas' raw-data='json'>{"stuff":23,"other":"data"}</script> </div> ``` ``` <div> <p>{{the_datas}}</p> <script initdata='{"stuff":23,"other":"data"}' ng-bind='the_datas' raw-data='json'></script> </div> ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,12 +10,12 @@ { var text = ($attrs.initdata ? $attrs.initdata : $element.text()); try{ if ($attrs.rawData.toLowerCase() == 'json') $scope[$attrs.ngBind] = angular.fromJson(text); }catch(e){ console.error(e); console.info('you sent:', text); console.info('raw-data was expecting:', $attrs.rawData); } } } -
Micka33 revised this gist
Jun 20, 2014 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,16 +6,16 @@ So I want to embed the datas in my page on the first request to load them direct #How to use rawData ``` <div> <p>{{the_datas}}</p> <script raw-data='' ng-bind='the_datas' type='json'>{"stuff":23,"other":"data"}</script> </div> ``` ``` <div> <p>{{the_datas}}</p> <scriptraw-data='' ng-bind='the_datas' type='json' initdata='{"stuff":23,"other":"data"}'></script> </div> ``` -
Micka33 revised this gist
Jun 20, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Why rawData (reminder) Because I don't want to have two requests to load one page (one for the squeleton, one for the datas). So I want to embed the datas in my page on the first request to load them directly. #How to use rawData -
Micka33 revised this gist
Jun 20, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #Why rawData (reminder) Because I don't want to have two request to load one page (one for the squeleton, one for the datas). So I want to embed the datas in my page on the first request to load them directly. #How to use rawData -
Micka33 revised this gist
Jun 20, 2014 . 2 changed files with 28 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,33 @@ #Why rawData (reminder) Because I don't want to have to request to load one page (one for the squeleton, one for the datas). So I want to embed the datas in my page on the first request to load them directly. #How to use rawData ``` <div class='line'> <p>{{the_datas}}</p> <script ng-bind='the_datas' raw-data='' type='json'>{"stuff":23,"other":"data"}</script> </div> ``` ``` <div class='line'> <p>{{the_datas}}</p> <script initdata='{"stuff":23,"other":"data"}' ng-bind='the_datas' raw-data='' type='json'></script> </div> ``` # What can be added more `if` can be added to be able to load strings/integers/booleans. ``` ... try{ if ($attrs.type.toLowerCase() == 'json') $scope[$attrs.ngBind] = angular.fromJson(text); ... ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ { if ( typeof $attrs.ngBind !== 'undefined') { var text = ($attrs.initdata ? $attrs.initdata : $element.text()); try{ if ($attrs.type.toLowerCase() == 'json') $scope[$attrs.ngBind] = angular.fromJson(text); -
Micka33 revised this gist
Jun 20, 2014 . 1 changed file with 0 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,3 @@ (function(window, angular, undefined) {'use strict'; angular.module('loadRawData', []) -
Micka33 renamed this gist
Jun 20, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Micka33 revised this gist
Jun 20, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #How to ``` -
Micka33 created this gist
Jun 20, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ #How to ```html ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ /** * @license AngularJS v1.2.14 * (c) 2010-2014 Google, Inc. http://angularjs.org * License: MIT */ (function(window, angular, undefined) {'use strict'; angular.module('loadRawData', []) .directive('rawData', [function() { return { restrict: 'A', link: function ($scope, $element, $attrs) { if ( typeof $attrs.ngBind !== 'undefined') { var text = ($attrs.initdata ? $attrs.initdatajson : $element.text()); try{ if ($attrs.type.toLowerCase() == 'json') $scope[$attrs.ngBind] = angular.fromJson(text); }catch(e){ console.error(e); console.info('you sent:', text); console.info('raw-data was expecting:', $attrs.type); } } } } }]); })(window, window.angular);