我试图在运行Grunt Build后查看我的应用程序.我使用grunt serve:dist来查看所有生产就绪的构建但是在浏览器中我得到一个无限循环说:
警告:试图加载角度不止一次.
我已经读过这个,因为在连接之后TemplateURL:可能是错误的.正如在这篇文章中: 试图加载Angular多次
但是我该如何解决这个问题呢?这是我的app.js
/* global libjsapp:true */
'use strict';
var libjsapp = angular.module('libjsApp', [
'ngCookies',
'ngResource',
'ngSanitize',
'ngRoute'
]);
libjsapp.config(['$routeProvider', function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/posts.html',
controller: 'PostsCtrl'
})
.otherwise({
redirectTo: '/'
});
}]);
Run Code Online (Sandbox Code Playgroud) 我想测试questionsBucket这个facotry
.factory('QA', function(ShuffleArray, RandWords){
var answersBucket = RandWords.get(9);
var questionsBucket = answersBucket;
var questionToRemove, answers, question;
var QA = {
answers: function(amount){
if(typeof(amount) === 'undefined') amount = 3;
answers = ShuffleArray.shuffle(answersBucket).slice(0,amount);
return answers;
},
question: function(){
questionToRemove = questionsBucket.indexOf(answers[Math.floor(Math.random() * 3)]);
question = questionsBucket.splice(questionToRemove, 1)[0];
return question;
}
};
return QA;
});
Run Code Online (Sandbox Code Playgroud)
正如您所看到的那样,它questionsBucket是一个未在QA对象中返回的变量,我不希望它暴露于使用它的任何东西.
在Ruby中有很多方法可以获取这些数据或访问私有方法,但我看不到如何在Angular中完成它.
以下是我想在Jasmine中编写测试的方法.
it('should remove a question from the questionsBucket',
inject(function(QA){
var answers = QA.answers(5);
var question = Qa.question();
//I can't access the questionBucket …Run Code Online (Sandbox Code Playgroud) .cpn .paymentPage .payment-fire .right {
font-weight: bold;
text-align: right;
position: relative;
margin-right: -27px;
margin-bottom: 20px;
}
Run Code Online (Sandbox Code Playgroud)
margin-right: -27px 与 margin-left: 309px 是不好的做法吗?
angularjs ×2
bdd ×1
css ×1
gruntjs ×1
jasmine ×1
javascript ×1
margin ×1
mocking ×1
pixel ×1
unit-testing ×1