Skip to content

Instantly share code, notes, and snippets.

@Usse
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save Usse/c7fd43861d74c15ab86d to your computer and use it in GitHub Desktop.

Select an option

Save Usse/c7fd43861d74c15ab86d to your computer and use it in GitHub Desktop.

Revisions

  1. Usse revised this gist Feb 19, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions data-binding-http-2.js
    Original file line number Diff line number Diff line change
    @@ -24,6 +24,7 @@
    };

    app.controller('MainController',MainController);
    //app.controller('MainController',['$scope', '$http', MainController]); <-- minifier friendly version

    }());
    </script>
  2. Usse revised this gist Feb 19, 2015. 1 changed file with 37 additions and 0 deletions.
    37 changes: 37 additions & 0 deletions data-binding-http-2.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    <!DOCTYPE html>
    <html ng-app="app">

    <head>
    <script data-require="[email protected]" data-semver="1.4.0-beta.4" src="https://code.angularjs.org/1.4.0-beta.4/angular.js"></script>
    <link href="style.css" rel="stylesheet" />
    <script>
    (function() {

    var app = angular.module('app', []);

    var MainController = function($scope, $http) {

    var onUserComplete = function(response) {
    $scope.user = response.data;
    };

    var onError = function(response) {
    $scope.error = "Could not fetch the user.";
    }

    $http.get('https://api.github.com/users/usse')
    .then(onUserComplete, onError);
    };

    app.controller('MainController',MainController);

    }());
    </script>
    </head>

    <body ng-controller="MainController">
    <div>{{error}}</div>
    <h1>{{user.name}}</h1>
    <img ng-src="{{user.avatar_url}}" title="{{user.name}}" width="200">
    </body>
    </html>
  3. Usse revised this gist Feb 19, 2015. 1 changed file with 32 additions and 0 deletions.
    32 changes: 32 additions & 0 deletions data-binding-http.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    <!DOCTYPE html>
    <html ng-app="app">

    <head>
    <script data-require="[email protected]" data-semver="1.4.0-beta.4" src="https://code.angularjs.org/1.4.0-beta.4/angular.js"></script>
    <link href="style.css" rel="stylesheet" />
    <script>
    angular.module('app', []).
    controller('MainController', ['$scope', '$http', function($scope, $http) {

    var onUserComplete = function(response) {
    $scope.user = response.data;
    };

    var onError = function(response) {
    $scope.error = "Could not fetch the user.";
    }

    $http.get('https://api.github.com/users/usse')
    .then(onUserComplete, onError);

    }]);

    </script>
    </head>

    <body ng-controller="MainController">
    <div>{{error}}</div>
    <h1>{{user.name}}</h1>
    <img ng-src="{{user.avatar_url}}" title="{{user.name}}" width="200">
    </body>
    </html>
  4. Usse revised this gist Feb 19, 2015. 1 changed file with 0 additions and 4 deletions.
    4 changes: 0 additions & 4 deletions data-binding.js
    Original file line number Diff line number Diff line change
    @@ -4,18 +4,14 @@
    <head>
    <script data-require="[email protected]" data-semver="1.4.0-beta.4" src="https://code.angularjs.org/1.4.0-beta.4/angular.js"></script>
    <link href="style.css" rel="stylesheet" />
    <!-- <script src="script.js"></script> -->

    <script>
    angular.module('app', []).
    controller('MainController', ['$scope', function($scope) {

    var person = {
    firstname : 'Andrea',
    lastname : 'Usseglio',
    imgSrc : 'https://pbs.twimg.com/profile_images/1599369214/312a6f2_200x200.jpg'
    }

    $scope.person = person;
    }]);
    </script>
  5. Usse created this gist Feb 19, 2015.
    28 changes: 28 additions & 0 deletions data-binding.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    <!DOCTYPE html>
    <html ng-app="app">

    <head>
    <script data-require="[email protected]" data-semver="1.4.0-beta.4" src="https://code.angularjs.org/1.4.0-beta.4/angular.js"></script>
    <link href="style.css" rel="stylesheet" />
    <!-- <script src="script.js"></script> -->

    <script>
    angular.module('app', []).
    controller('MainController', ['$scope', function($scope) {

    var person = {
    firstname : 'Andrea',
    lastname : 'Usseglio',
    imgSrc : 'https://pbs.twimg.com/profile_images/1599369214/312a6f2_200x200.jpg'
    }

    $scope.person = person;
    }]);
    </script>
    </head>

    <body ng-controller="MainController">
    <h1>{{person.firstname + " " + person.lastname}}</h1>
    <img ng-src="{{person.imgSrc}}" title="{{person.firstname}} {{person.lastname}}">
    </body>
    </html>