无法找到任何探索Angular此类问题的资源,如果您知道任何事情,请随时将我链接到正确的方向.
我正在使用Angular为移动设备建立一个在线商店(在这个阶段只有移动设备).
系统的核心是产品(每个产品都有名称,设计师,描述,颜色,价格,类别,商店位置和其他一些产品).
我现在将所有这些存储在JSON文件中并将其加载到Angular中,但是我添加的产品越多,这就变得越难以管理.
我想做什么:
我想要一个可以发送一些查询的数据库(例如:"男士,衬衫,
我唯一接触过的后端系统是MySQL(并没有那么多).我知道足够的PHP让我自己,我会说初学者 - 中级(我是一个前端开发者).
这种东西最适合任何特定类型的数据库吗?AngularJS有什么特别的"玩得好"吗?
我在我的应用程序的"索引"页面上使用AngularUI Typeahead.我没有做任何花哨的事 - 事实上,我只是试图让他们在他们的UI网站上工作的例子,我收到这个错误:
Error: Template must have exactly one root element
Run Code Online (Sandbox Code Playgroud)
我不知道这意味着什么,但只有当我有以下代码时才会发生:
<input type="text" ng-model="selected" typeahead="state for state in states | filter:$viewValue">
Run Code Online (Sandbox Code Playgroud)
如果相关的,我的控制器,我的主要页面(这是通过所谓$routeProvider
的/
索引目录):
function indexCtrl($scope, $location, $resource) {
$scope.selected = undefined;
$scope.states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Dakota', 'North Carolina', …
Run Code Online (Sandbox Code Playgroud) 我将以这样一个事实为前提:我真的不知道这是否是实现我正在做的事情的最佳方式,而且我对更好的建议非常开放.
我有一个用户帐户系统使用OAUTH2
它来查找我的数据库中的用户信息并将其保存为变量,$rootScope.userInfo
.它驻留在一个附加到我的应用程序的控制器中body
; 在这里,我认为最高级别的控制器会在其中存在之前加载,但显然不是.
如果我加载了一个试图$rootScope.userInfo
在我mainCtrl
有机会从我的数据库加载它之前尝试访问该对象的视图,它会抛出一个javascript错误并Angular
中断.
作为参考,这里是模板的粗略概念:
<body ng-controller="mainCtrl">
<header>Content</header>
<div class='main-view' ng-controller="userProfile">
<p>{{user.name}}</p>
<p>{{user.email}}</p>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
我加载$rootScope.userInfo
在mainCtrl
这样的:
$http.get('/api/users/' + $cookies.id).
success(function(data) {
$rootScope.userInfo = data.user[0];
console.log("User info is:");
console.log($rootScope.userInfo);
$scope.status = 'ready';
});
Run Code Online (Sandbox Code Playgroud)
然后为了我的userProfile
控制,我做:
function userProfile($scope, $cookies, $http, $routeParams, $rootScope){
if($scope.status == 'ready'){
$scope.user = $rootScope.userInfo;
console.log("Double checking user info, here it is:");
console.log($rootScope.userInfo);
}
}
Run Code Online (Sandbox Code Playgroud)
如果我来自应用程序中不打开的其他页面$rootScope.userInfo
,则API有足够的时间查找并且我的userProfile
页面工作正常.但是,如果进行整页刷新,$rootScope.userInfo
则没有时间加载,我会收到错误. …
我有一堆HTML元素,我想通过Canvas与行连接.这是我正在努力实现的模型:
目前,我只有线条,没有文字.我想在每一行之间放置文字,但看到它们是对角线,我不知道该怎么做.
当前代码:
// 'connectors' is an array of points corresponding to
// the middle of each big blue buttons' x-value
ctx.clearRect(0,0,canvas.width,canvas.height);
for(var i=0;i<connectors.length;i++){
var wpoint = connectors[i];
var pos1 = {w: wpoint, h: 0};
var pos2 = {w: canvas.width / 2, h: canvas.height};
ctx.beginPath();
ctx.moveTo(pos1.w,pos1.h);
ctx.lineTo(pos2.w,pos2.h);
ctx.stroke();
// Write Text Halfway
ctx.fillStyle = "blue";
ctx.font = "bold 16px Arial";
ctx.fillText("2702", 100, canvas.height / 2);
// No idea what to put as the x value here
}
Run Code Online (Sandbox Code Playgroud)
实现这一目标的最佳方法是什么?潜在地绘制一半的线,写文本,然后绘制剩余的线?
编辑:也许更好的标题/问题是:如何在HTML …
我不介意这是用一个单独的程序,使用Excel,在NodeJS或Web应用程序中完成的.
这与此处描述的问题完全相同:
OP似乎没有得到工作的答案(但还是接受了吗?).我已经尝试过使用它,但似乎无法让它工作.
简而言之:我正在使用~50,000行CSV,我想将其转换为JSON.我已经尝试了几乎所有在线"csv to json"webapp,所有这些都与这个庞大的数据集崩溃.
我已经尝试了很多Node
CSV到JSON模块,但是,它们都崩溃了.该csvtojson
模块似乎很有希望,但我得到了这个错误:FATAL ERROR: JS Allocation failed - process out of memory
.
我怎样才能以可用的格式获取这些数据?如上所述,我不介意它是一个应用程序,一个在Excel,webapp或Node模块中工作的东西,只要我得到一个.JSON
文件或一个我可以在Node中使用的对象.
有任何想法吗?
这可能是一个难以回答的问题,因为我不确定这里的根本问题是什么,如果有人想看看会很感激.
http://threadfinder.net/search%3FnameTags=jacket/0
如果您不断向下滚动,则使用ngInfiniteScroll和此函数加载更多项目:
$scope.moreProducts = function() {
if ($scope.busy || $scope.noMore){return;}
else
if (!($scope.busy)) {
$scope.busy = true;
$scope.itemsLoaded += 27;
var theQuery = $routeParams.query.replace(/\?|%3f/gi, '');
$scope.itemSearch.get({
query: theQuery,
page: $scope.itemsLoaded
}, function(data) {
if (data.posts.length <= 0) {
$scope.noMore = true;
} else {
$scope.noMore = false;
for (var i = 0; i < data.posts.length; i++) {
if ($scope.user) {
if (!($scope.user.likes.indexOf(data.posts[i]._id) === -1)) {
data.posts[i].liked = 'http://i.imgur.com/CcqoATE.png';
} else {
data.posts[i].liked = 'http://i.imgur.com/tEf77In.png';
}
$scope.posts.push(data.posts[i]);
} …
Run Code Online (Sandbox Code Playgroud) javascript performance mongodb angularjs angularjs-directive
我发现文档非常缺乏这一点(或者,我很愚蠢),但这是我的设置:
Webapp 运行于Node
和Express
, 中port 8080
。它还与 MongoDB 容器连接(这就是我使用 MongoDB 的原因docker-compose
)。
在我的 Dockerfile 中,我有:
FROM node:4.2.4-wheezy
# Set correct environment variables.
ENV HOME /root
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install;
# Bundle app source
COPY . /usr/src/app
CMD ["node", "app.js"]
EXPOSE 8080
Run Code Online (Sandbox Code Playgroud)
我跑:
docker-compose build web
docker-compose build db
docker-compose up -d db
docker-compose up -d web
Run Code Online (Sandbox Code Playgroud)
当我跑步时,docker-machine ip default
我得到了192.168.99.100
。
因此,当我在浏览器中访问时192.168.99.100:8080
,我希望看到 …
我在 Express 中设置了一个简单的 API 路由(主要通过我的 Angular 前端使用):
app.post('/api/sendEmail', emailApi.sendEmail);
Run Code Online (Sandbox Code Playgroud)
我已经制作了一个位于后端的模块,并且还需要调用此服务。我认为最简单的方法是执行 POST 请求:
request({
url: '/api/sendEmail',
method: 'POST',
json: {
template: template.toLowerCase(),
obj: mailObj
}
}, function(error, response, body){
console.log('error', error);
console.log('response', response);
console.log('body', body);
});
Run Code Online (Sandbox Code Playgroud)
但是,我收到此错误:
Error: Invalid URI "/api/sendEmail"
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么?
之前已经在这里提出过类似的问题,但在阅读完之后我还没有找到适用于我的网站的答案.
我在Bootstrap周围构建了这个网站,但添加了一些我自己的媒体查询.现场测试网站位于:http://agoodman.com.au
媒体查询更改的部分是"我们的费用"和"地图"覆盖.如果您使用的是笔记本电脑,则调整浏览器大小会使这些部分显示为块.
我的样式表链接:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/user.css" rel="stylesheet">
Run Code Online (Sandbox Code Playgroud)
"User.css"只是一个单独的文件,因为我希望能够在必要时保留和更新bootstrap的主框架.User.css覆盖引导程序中的样式.我在user.css中的媒体查询如下:
@media screen or handheld(max-width: 979px) {
.fee-buttons {
height: auto;
font-weight: 600;
position: relative;
padding: 0;
margin: 0;
list-style: none;
}
.fee-buttons .transformation {
width: 100% !important;
height: 300px;
position: relative;
z-index: 10;
left:0;
}
.fee-buttons .hourly, .fee-buttons .membership {
float: none;
width: 100% !important;
}
li.button{
overflow:visible;
}
}
@media screen or handheld(max-width: 995px) {
#overlay {
position: relative;
display: block; …
Run Code Online (Sandbox Code Playgroud) 假设我有两个我要比较的对象数组:
var arr1 = [
{
name: 'A', type: "Dog"
},
{
name: 'B', type: "Zebra"
},
{
name: 'C', type: "Cat"
},
{
name: 'D', type: "Dingo"
}
]
var arr2 = [
{
name: 'A', type: "Wolf"
},
{
name: 'B', type: "Echidna"
},
{
name: 'C', type: "Wallaby"
},
{
name: 'D', type: "Rabbit"
}
]
Run Code Online (Sandbox Code Playgroud)
假装这arr1
是旧数据,并且arr2
是来自API的更新数据.
我想遍历数组,找到name
匹配的对象.如果有匹配,我想更新type
from arr1
到arr2
.
我这样做是这样的:
for(var i = 0; i<arr1.length; i++){ …
Run Code Online (Sandbox Code Playgroud) javascript ×7
angularjs ×4
node.js ×3
json ×2
performance ×2
angular-ui ×1
canvas ×1
css3 ×1
csv ×1
database ×1
deployment ×1
docker ×1
dockerfile ×1
ecmascript-6 ×1
excel ×1
express ×1
html5 ×1
mobile ×1
mongodb ×1
php ×1