Answer the question
In order to leave comments, you need to log in
How to fix template rendering in angular?
I'm going through the angular tutorial, I've done the distribution over various files (controllers separately, templates separately, etc.). When connected, nothing is displayed, absolutely. Here is the code from index.php client:
<!DOCTYPE html>
<html>
<head>
<title>Angular</title>
<script src="angular-js/angular.js"></script>
<script src="test.js"></script>
<script src="controllers.js"></script>
</head>
<body ng-app='NewAppModule'>
<div ng-view></div>
</body>
</html>
angular.module('NewAppModule', []);
angular.module('NewAppModule', []).
component('div', {
templateUrl: 'template.html',
controller: 'ContactView' <----Проблема возникает при подключении контроллера в этом месте.
});
<p>
Поиск: <input type='text' ng-model='search' placeholder='Поиск..'>
</p>
<p>
Сортировка: <select ng-model='sort'>
<option value='name'>По имени</option>
<option value='number'>По номеру</option>
</select>
</p>
<ul>
<li ng-repeat="people in $ctrl.contact | filter: search | orderBy: sort" style="list-style: none">
<p>Имя: <a href="/contacts/{{people.name}}">{{people.name}}</a></p>
<p>Телефон: {{people.number}}</p>
<hr>
</li>
</ul>
var ctrl=angular.module('NewAppModule', []);
ctrl.controller('ContactView',['$http', function($http){
var self=this;
var url='/app.json';
$http({url: url, method:'GET'}).then(function(response) {
self.contact=response.data;
});
}]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question