1

I'm simply having trouble figuring out why the angular expressions aren't being displayed when I try and view them on a browser. I'm trying to embed an ng-repeat into an unordered list, however the html shows as:

{{country.name}}

{{city.name}}

This is what I have:

<!doctype html>
<html>
  <head>
    <script src="Scripts\angular.js"></script>
    <script src="Scripts\script.js"></script>
  </head>
  <body ng-app="myModule" style="font-family:Arial">
    <div ng-controller="myController">
      <ul>
          <li ng-repeat="country in countries">
              {{country.name}}
                  <ul>
                    <li ng-repeat="city in country.cities">
                        {{city.name}}
                    </li>
                  </ul>
          </li>
      </ul>
    </div>
  </body>
</html>




var myApp = angular
                  .module("myModule", [])
                  .controller("myController", function($scope) {
                      var countries = [
                        {
                          name: "UK",
                          cities: [
                              { name: "London" },
                              { name: "Manchester" },
                              { name: "Portsmouth" }
                          ]
                        },
                        {
                          name: "USA",
                          cities: [
                              { name: "New York" },
                              { name: "Trenton" },
                              { name: "Philidelphia" }
                          ]
                        },
                        {
                          name: "Poland"
                          cities: [
                              { name: "Warsaw" },
                              { name: "Poznan" },
                              { name: "Lodz" }
                          ]
                         }
                      ];
                          $scope.countries = countries;
                      });
1
  • 1
    Open the browser's console and check if there are any error messages. Commented Jan 9, 2017 at 15:02

1 Answer 1

3

you are missing , after poland

 name: "Poland"

Fix this and everything should be OK

var myApp = angular.module("myModule", []).controller("myController", function($scope) {
  
  
  var countries = [{
    name: "UK",
    cities: [{
      name: "London"
    }, {
      name: "Manchester"
    }, {
      name: "Portsmouth"
    }]
  }, {
    name: "USA",
    cities: [{
      name: "New York"
    }, {
      name: "Trenton"
    }, {
      name: "Philidelphia"
    }]
  }, {
    name: "Poland",
    cities: [{
      name: "Warsaw"
    }, {
      name: "Poznan"
    }, {
      name: "Lodz"
    }]
  }];
  $scope.countries = countries;
});
<!doctype html>
<html>

<head>
   <script data-require="[email protected]" src="https://code.angularjs.org/1.4.12/angular.js" data-semver="1.4.9"></script>

</head>

<body ng-app="myModule" style="font-family:Arial">
  <div ng-controller="myController">
    <ul>
      <li ng-repeat="country in countries">
        {{country.name}}
        <ul>
          <li ng-repeat="city in country.cities">
            {{city.name}}
          </li>
        </ul>
      </li>
    </ul>
  </div>
</body>

</html>

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

Comments

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.