Created
March 12, 2015 08:57
-
-
Save andipollok/0316f4372bfa16180184 to your computer and use it in GitHub Desktop.
JS Bin Load and display CSV using an Angular controller and a directive // source http://jsbin.com/toxucitidi
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 characters
| <!DOCTYPE html> | |
| <html ng-app='test'> | |
| <head> | |
| <meta name="description" content="Load and display CSV using an Angular controller and a directive"> | |
| <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script> | |
| <meta charset="utf-8"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body ng-controller="testCtrl"> | |
| <test-directive> | |
| <pre>{{data}}</pre> | |
| </test-directive> | |
| <script id="jsbin-javascript"> | |
| var app = angular.module('test', []); | |
| app.controller('testCtrl', ['$scope', '$http', function($scope, $http) { | |
| var url = 'http://mysafeinfo.com/api/data?list=dowjonescompanies&format=csv'; | |
| $http.get(url).success(function(data) { | |
| $scope.data = data; | |
| }); | |
| }]); | |
| app.directive('testDirective', [function() { | |
| return { | |
| restrict: 'E', | |
| link: function($scope, element, attrs) { | |
| $scope.$watch('data', function() { | |
| console.log('watch data', $scope.data); | |
| // do something with data here, like a visualisation | |
| }); | |
| } | |
| }; | |
| }]); | |
| </script> | |
| <script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
| <html ng-app='test'> | |
| <head> | |
| <meta name="description" content="Load and display CSV using an Angular controller and a directive"> | |
| <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"><\/script> | |
| <meta charset="utf-8"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body ng-controller="testCtrl"> | |
| <test-directive> | |
| <pre>{{data}}</pre> | |
| </test-directive> | |
| </body> | |
| </html></script> | |
| <script id="jsbin-source-javascript" type="text/javascript">var app = angular.module('test', []); | |
| app.controller('testCtrl', ['$scope', '$http', function($scope, $http) { | |
| var url = 'http://mysafeinfo.com/api/data?list=dowjonescompanies&format=csv'; | |
| $http.get(url).success(function(data) { | |
| $scope.data = data; | |
| }); | |
| }]); | |
| app.directive('testDirective', [function() { | |
| return { | |
| restrict: 'E', | |
| link: function($scope, element, attrs) { | |
| $scope.$watch('data', function() { | |
| console.log('watch data', $scope.data); | |
| // do something with data here, like a visualisation | |
| }); | |
| } | |
| }; | |
| }]);</script></body> | |
| </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 characters
| var app = angular.module('test', []); | |
| app.controller('testCtrl', ['$scope', '$http', function($scope, $http) { | |
| var url = 'http://mysafeinfo.com/api/data?list=dowjonescompanies&format=csv'; | |
| $http.get(url).success(function(data) { | |
| $scope.data = data; | |
| }); | |
| }]); | |
| app.directive('testDirective', [function() { | |
| return { | |
| restrict: 'E', | |
| link: function($scope, element, attrs) { | |
| $scope.$watch('data', function() { | |
| console.log('watch data', $scope.data); | |
| // do something with data here, like a visualisation | |
| }); | |
| } | |
| }; | |
| }]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment