这段代码让我
error angular.js:13920 TypeError: Cannot read property 'insertBefore' of null
at after
之后我添加了ngRepeat,无法理解发生了什么。当我从获取请求和模板得到响应时,有兴趣知道关于自我的错误已经被证明是正确的。
模板
<ui-view ng-controller="VacansyContorller" class="layout-vacansy-list-view">
<h4>Всего <% vacansyList.count %> <% ending %></h4>
{# {% for vacansy in vacansy_list %} #}
<div ng-if="vacansyList.count">
<div ng-repeat="vacansy in vacansyList.results">
<hr />
<div class="vacansy-item">
<h3 class="vacansy-title"><b><% vacansy.title %></b></h3>
<span class="vacansy-about">
<blockquote><% vacansy.short_text %></blockquote>
</span>
<div class="vacansy-container">
<div class="vacansy-last-info-container">
<span class="text-muted"><i class="fa fa-circle-o" aria-hidden="true"></i> <% vacansy.city %></span>
<span class="text-muted"><% vacansy.reward %> <i class="fa fa-usd" aria-hidden="true"></i></span>
</div>
<div class="vacansy-creator-container">
<img class="vacansy-img" ng-if="vacansy.author.avatar" ng-src="<% vacansy.author.avatar %>">
<i ng-if="!vacansy.author.avatar" class="fa fa-user fa-3x" aria-hidden="true"></i>
<span class="text-primary vacansy-creator"><% vacansy.author.username %></span>
<span class="text-muted created-date-decorator"><small>Опубликовано</small></span>
<cite title="Source Title">
<span class="vacansy-created-date"><% vacansy.created %></span>
</cite>
</div>
</div>
</div>
</div>
</div>
<ui-view/>
app.js
(function () {
'use strict';
var config = function($stateProvider, $interpolateProvider){
$interpolateProvider.startSymbol('<%');
$interpolateProvider.endSymbol('%>');
// $stateProvider.state({
// name: 'default',
// url: '/',
// templateUrl: 'static/main/index.html'
// });
// $stateProvider.state({
// name: 'test',
// url: '/test',
// template: '<h1>HELOQOWEQWEWQ</h1>'
// });
};
var run = function(){
};
var JustDance = angular.module('JustDance', ['ui.router'])
.config(['$stateProvider', '$interpolateProvider', config])
.run([run]);
JustDance.factory('vacansyFactory', function ($http, $q){
this.getVacansyList = function(){
return $http.get('/vacansy/')
.then(function(response) {
return response.data
});
}
return this;
});
JustDance.controller('VacansyContorller',
['$scope', '$http', 'vacansyFactory',
function($scope, $http, vacansyFactory){
$scope.vacansyList = [];
$scope.getNumberEnding = function(number, words){
number = number % 100;
if (number >= 11 && number <= 19)
return words[2];
number = number % 10;
if (number == 1) {
return words[0];
} else {
if (number == 2 || number == 3 || number == 4) {
return words[1];
} else {
return words[2];
}
}
}
vacansyFactory.getVacansyList()
.then(function(data){
$scope.vacansyList = data;
$scope.ending = $scope.getNumberEnding(data.count, ['предложение', 'предложения', 'предложений'])
});
}]
);
})();
请你注意。