Я пытался следить за видео Дэна Уолина на YouTube и реализовывать его параллельно, используя свои собственные данные. Бэкэнд находится в экспрессе и монго, и приведенный ниже код работал до того момента, когда я начал добавлять маршруты. Два связанных файла существуют, и все работает на сервере, что исключает проблемы с похожими плакатами, но частичные не загружаются (я вижу некоторые признаки того, что заглушка ng-view была изменена angular, но без внедрения новый контент). Любые подсказки?
<html ng-app="restosApp">
<head>
</head>
<body>
<div>
<div data-ng-view></div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.2/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.2/angular-route.min.js"></script>
<script>
var app = angular.module('restosApp', ['ngRoute']);
app.controller('listController', function($scope, restosFactory) {
function init() {
restosFactory.getQnames().success(function(data){
$scope.qnames = data;
});
}
init();
});
app.controller('editorController', function($scope, restosFactory) {
function init() {
restosFactory.getFullData('marius').success(function(data){
$scope.resto = data;
});
}
init();
});
app.config(function ($routeProvider) {
$routeProvider
.when('/', {
controller: 'listController',
templateURL: 'qname.html'
})
.when('/edit', {
controller: 'editorController',
templateURL: 'editor.html'
})
.otherwise({
redirectTo: '/'
});
});
app.factory('restosFactory', function($http){
var factory = {};
factory.getQnames = function() {
return $http.get('http://localhost:3000/data');
};
factory.getFullData = function(q) {
return $http.get('http://localhost:3000/edit?qname='+q);
};
return factory;
});
</script></body>
На экспресс-стороне у меня есть
app.get '/qname.html', (req, res) ->
res.sendfile 'qname.html'
app.get '/editor.html', (req, res) ->
res.sendfile 'editor.html'
и http://localhost:3000/qname.html
возвращает содержимое (ниже) файла, казалось бы, правильно
<section class="container">
<label>search qName:</label>
<input type="text" ng-model="searchname" placeholder="Enter a name here">
<div ng-repeat="qname in qnames | filter: searchname | orderBy: 'date':true"> <!-- Newest first -->
<a href="/edit?qname={{qname.qname}}">{{qname.rname}}</a>
</div>
</section>
http://localhost:3000/#/
В консоли вообще ничего нет - person Simon H   schedule 16.03.2014localhost:3000
и файлы .js - person Simon H   schedule 16.03.2014