0

Good Night!

I'm trying to implement a ASP.NET API, but I can't figure out why my angular doesn't compile correctly!

I just created a new empty web Project, added angular and through NUGET, and I'm trying to add the scripts like this.

Index.html

<!DOCTYPE html>
<html>

<head ng-app="palladarApp">
  <title>CodeBranch - Palladar</title>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
</head>

<body ng-controller="palladarCtrl">
  <div>
    <header></header>
    <section>{{ teste }}</section>
    <hr />
    <section>{{ 13 + 31 }}</section>
    <footer></footer>
  </div>

  <!--Load Libraries-->
  <link href="Content/bootstrap.min.css" rel="stylesheet" />
  <script src="Scripts/jquery-2.1.4.js"></script>
  <script src="Scripts/angular.js"></script>
  <script src="Scripts/i18n/angular-locale_pt-br.js"></script>
  <script src="Scripts/angular-route.js"></script>
  <script src="Scripts/angular-animate.js"></script>

  <!--Load Scripts-->
  <script src="app/Controllers/palladarController.js"></script>
</body>

</html>

PalladarController.js

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

app.controller('palladarCtrl', ['$scope', '$http', '$modal', function($scope, $http, $modal) {

  $http.defaults.headers.post['Content-Type'] = 'application/json';

  $scope.teste = "HUE HUE HUE";
}]);

When I run the Project, I just saw at my browser the codes..

{{ teste }}
{{ 13 + 31 }}

If I open the browser console (F12) it doesn't show any errors.

1
  • 1
    You need to add ng-app attribute on <html> tag instead of <head>. Commented Sep 25, 2015 at 1:09

1 Answer 1

1

You need to put: ng-app="palladarApp" inside html tag, something like this:

<!DOCTYPE html>
<html ng-app="palladarApp">
<head>
  <title>CodeBranch - Palladar</title>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
</head>

<body ng-controller="palladarCtrl">
  <div>
    <header></header>
    <section>{{ teste }}</section>
    <hr />
    <section>{{ 13 + 31 }}</section>
    <footer></footer>
  </div>

  <!--Load Libraries-->
  <link href="Content/bootstrap.min.css" rel="stylesheet" />
  <script src="Scripts/jquery-2.1.4.js"></script>
  <script src="Scripts/angular.js"></script>
  <script src="Scripts/i18n/angular-locale_pt-br.js"></script>
  <script src="Scripts/angular-route.js"></script>
  <script src="Scripts/angular-animate.js"></script>

  <!--Load Scripts-->
  <script src="app/Controllers/palladarController.js"></script>
</body>

</html>

Sign up to request clarification or add additional context in comments.

1 Comment

Omg, My bad, I'm just looking for the code for like two hours and didn't saw that. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.