T
T
tupoi2016-10-15 02:01:33
JavaScript
tupoi, 2016-10-15 02:01:33

How to include angularjs module?

Good day, the application on angularjs does not work, there are 2 files, index.html and app.js

<!DOCTYPE html>
<html lang="ru">
<head>
  <meta charset="UTF-8">
  <title>Angular JS</title>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
</head>
<body ng-app="app">

<div ng-controller="MainCtrl">
  <ul>
      <li ng-repeat="item in items">
          {{ item.name }}
      </li>
  </ul>
</div>

</body>
</html>

function MainCtrl ($scope) {
  $scope.items = [{
    name: 'Андрей',
    id: 7297510
  },{
    name: 'Петр',
    id: 0278916
  },{
    name: 'Иван',
    id: 2389017
  },{
    name: 'Дмитрий',
    id: 1000983
  }];
}


var app = angular
    .module('app')
    .controller('MainCtrl', MainCtrl);

But for some reason nothing is displayed when index.html is opened (only "{{ item.name }}" is displayed), what am I missing? The files are in the same directory

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Manakov, 2016-10-15
@tupoi

Perhaps instead
of inserting
.module('app', [])

A
Alexander Korotaev, 2016-10-15
@lekzd

app.js not included?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question