Last active
July 10, 2017 19:25
-
-
Save Danyboy/ca9f27905d9f898937ed26653fc797aa to your computer and use it in GitHub Desktop.
Angular bugs
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> | |
| <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> | |
| <body> | |
| <div ng-app="myApp" ng-controller="myCtrl"> | |
| <p>Today's welcome message is:</p> | |
| <h1>{{myWelcome}}</h1> | |
| </div> | |
| <p>The $http service requests a page on the server, and the response is set as the value of the "myWelcome" variable.</p> | |
| <script> | |
| var app = angular.module('myApp', []); | |
| app.controller('myCtrl', function($scope, $http) { | |
| $http.get("https://api.github.com/repos/angular/angular/issues") | |
| .then(function(response) { | |
| $scope.myWelcome = []; | |
| angular.forEach(response.data, function(value, key) { | |
| if (value && value.labels[0] && value.labels[0].color){ | |
| this.push(key + ': ' + value.labels[0].color); | |
| } | |
| }, $scope.myWelcome); | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment