Search code examples
htmlangularjs-service

get data from server with angularjs


<!doctype html>
<html lang='en'>
    <head>
        <meta charset-"UTF-8">
        <title>devang</title>
        <link rel="stylesheet" href="bootstrap.css">
        <script> src="lib/onsen/js/angular/angular.min.js" </script>
        <script> src="lib/onsen/js/angular/angular.js" </script>
    </head>
    <body>
        <div class="container" ng-app="App">
            <div ng-controller="controller">
                <ul>
                    <li ng-repeat="artist in artists">
                        {{artist.name}}
                    </li>
                </ul>
            </div>
        </div>

        <script>
            angular.module('App',[]).
            controller('controller',function($scope,$http){
                $http.get('artists.json').success(function(data){
                    $scope.artists = data;
                });

            });
        </script>
    </body>
</html>

when i execute it shows error

  1. angular is not defined
  2. The character encoding of the HTML document was not declared.

The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. need your suggesions


Solution

  • Your script tags are defined incorrectly. the SRC should be an attribute of the script tag.

    <script src="lib/onsen/js/angular/angular.min.js"></script>
    <script src="lib/onsen/js/angular/angular.js"></script>