小编cod*_*mer的帖子

使用AngularJS $资源获取数据

我试图使用$ resource从静态json文件中获取数据,这里是代码片段:

 angular.module('app.services', ['ngResource']).
  factory('profilelist',function($resource){
    return $resource('services/profiles/profilelist.json',{},{
        query:{method:'GET'}
    });
});
Run Code Online (Sandbox Code Playgroud)

在控制器中,

function ProfileCtrl($scope,profilelist) {
$scope.items = [];
$scope.profileslist = profilelist.query();
for (var i=0;i<=$scope.profileslist.length;i++){
    if($scope.profileslist[i] && $scope.profileslist[i].profileid){
        var temp_profile = $scope.profileslist[i].profileid;
    }
    $scope.items.push(temp_profile);

}
Run Code Online (Sandbox Code Playgroud)

但现在,我面临一个错误: TypeError: Object #<Resource> has no method 'push'

你能在我出错的地方帮助我吗?

javascript angularjs

12
推荐指数
1
解决办法
3万
查看次数

我应该使用Scala,Java还是Node.js?

我非常了解Scala编程语言.到目前为止,我理解了有关Scala的以下概念:

  • 在传统的JVM上运行
  • 可与Java互操作
  • 结合OOP和函数式编程概念
  • 静态类型和可扩展
  • 更少的代码和更多的范例

我的要求很简单.我必须编写一个业务模块,该模块遵循一组应在运行时动态加载的预定义规则.例如,公司A有一套业务规则,公司B有另一套业务规则.当另一个程序访问业务模块API时,它应该加载该特定公司的规则并响应该服务.业务模块将涉及数据库访问和内部的更多Web服务调用以及广泛的xml解析.

我们需要这个模块尽可能地扩展.我可以使用JAVA的AOP概念,但它太复杂了.该代码将来无法维护.

在这种情况下,Scala是更好的选择吗?我甚至在考虑Node.js

请让我知道你的想法!

scala node.js

5
推荐指数
0
解决办法
1203
查看次数

nodejs 集群模块 - 地址使用错误

我有一个 express.js 应用程序,它必须在每次有特定请求时运行一个子进程(这里是: /compute/real-time )。将有用户创建的脚本来计算数据。所以,我使用节点集群模块来创建一个工作池并选择一个可以自由执行脚本的工作。但是我在创建集群本身的过程中遇到了麻烦。这是代码 clusterPool.js

var cluster = require('cluster');
exports.setupCluster = function(){
console.log ("Setting up cluster for bot processing " )
  if (cluster.isMaster){
    cluster.fork();   //one is good enough at the moment
  }
}
Run Code Online (Sandbox Code Playgroud)

计算.js

var async = require('async');
var clusterPool = require('.././clusterPool')
//Start the cluster
clusterPool.setupCluster();
exports.computeRealTime = function(req,res){
    clusterPool.cluster.on("listening",function(worker){
        //....Do something with the worker
    })
}
Run Code Online (Sandbox Code Playgroud)

网络服务器.js

// Include Express
var express = require('express');
var compute = require('.././compute');

// Create a new Express application
var app = express(); …
Run Code Online (Sandbox Code Playgroud)

javascript cluster-computing node.js express

5
推荐指数
1
解决办法
1850
查看次数