$http.get() error not showing html page content

56 views
Skip to first unread message

neerav patel

unread,
Feb 1, 2016, 6:29:21 AM2/1/16
to AngularJS
i m beginner plz can you help me that why content on welcome.html is not beign shown
what should i do please rply fast
{i am using notepad++ as editor}

<!DOCTYPE html>

<html>
<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("welcome.html")
  .then(function(response) {
      $scope.myWelcome = response.data;
  });
});
</script>

</body>
</html>



welcome.html

<html><head>

</head>
<body>

<h1 style="color:green">Bievenue! Angular JS du Page</h1>

</body>
</html>

Bill Boyle

unread,
Feb 4, 2016, 2:57:49 PM2/4/16
to AngularJS
First, you should make welcome.html contain only the h1 tag, not html/head/body tags.  And you should handle if $http fails:


$http.get("welcome.html")
  .then(function(response) {
      $scope.myWelcome = response.data;
  }, function(response) {
      alert("Error trying to get welcome.html!");
  });

neerav patel

unread,
Feb 5, 2016, 4:44:28 AM2/5/16
to ang...@googlegroups.com
thank you bill for ur assistance....
but $http failed showing your error message.....
plz enlighten me more on this plz

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/t54x-k7SRU0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

error.jpg

neerav patel

unread,
Feb 5, 2016, 4:59:49 AM2/5/16
to ang...@googlegroups.com
even this is not running properly




var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
    $http({
        method : "GET",
        url : "welcome.html"
    }).then(function mySucces(response) {
        $scope.myWelcome = response.data;
    }, function myError(response) {
        $scope.myWelcome = response.statusText;
    });
});

On Fri, Feb 5, 2016 at 1:27 AM, Bill Boyle <bill.b...@gmail.com> wrote:

--
Reply all
Reply to author
Forward
0 new messages