我试图通过Angular.js Tutrorial_00,似乎无法弄清楚如何让node.js Web服务器运行演示应用程序?
有没有人完成本教程或知道如何正确使用此步骤来使服务器工作?
node scripts\web-server.js以启动Web服务器.打开浏览器窗口http://localhost:8000/app/index.html会发生什么是我在node.js中运行第1步然后输出"...",我认为它正在监听.
然后当我进入第2步时,我在浏览器中输入"哎呀!Google Chrome无法连接".
只是想知道异步时最好的方法.起初我的代码看起来像这样(示例简化了).
public NotificationSummary SendNotification()
{
var response = new NotificationSummary();
var first = FindSubscriptions(1);
...
var seventh = FindSubscriptions(7);
Task.WaitAll(first, ... , seventh);
response.First = first.Result;
...
response.Seventh = seventh.Result;
return response;
}
private Task<NotificationResult> FindSubscriptions(int day)
{
return Task.Run(() =>
{
var subscriptions = // call to database to get list of subscriptions
var tasks = subscriptions.Select(x => SendOutNotification(x))
var results = Task.WhenAll(tasks).Result.ToList();
return // map results to NotificationResult
}
}
private Task<IndividualResult> SendOutNotification(Subscription subscription)
{
return Task.Run(() => …Run Code Online (Sandbox Code Playgroud) public class Person
{
public string Email {get; set;}
public string Name {get; set;}
}
public Report : Dictionary<string, string>
{
public Report()
{
List<Person> list = getData(); // filled with Person's
var realList = list.Where(x => x.Name != "test");
foreach( var i in realList)
{
this.Add(i.Email,i.Name);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我试图简化我的代码以解决问题.基本上我有一个人员列表,我想得到一个子列表,然后对于子列表中的每个元素,我想将它添加到这个类的字典中.
我的问题:有没有办法摆脱那个foreach语句,并在上面的linq语句中实现相同的效果.因为看一次然后再通过子列表对我来说似乎很愚蠢.那么如果在linq语句中如果x.Name不等于test那么它会将它添加到字典中会有什么好处.
我不知道将所有这些组合在一起是否是一个好主意,如果我做了不正确或愚蠢的事情,请告诉我是否应该把这篇文章记下来.但我只是升级了大学并且正在进入一个入门级的工作,我即将进行技术评估,处理一些比我不熟悉的更多的东西:Angular,SignalR和WebAPI.
作为入门级候选人:有什么问题我应该准备好被问及回答?
我可以找到更多关于Angular的面试问题而不是其他两个,但任何网站或问题的知识都会非常感激.
现在我正试图通过观察每个教程来获得对每个教程的基本理解,但我知道这将是每个广泛领域的大量信息,所以我试图了解我真正需要的部分集中我的专注范围.
谢谢!
我有一个角度控制器,它是一个Web API方法的帖子.我试图在ienumerable上添加null安全性,但是当我这样做时,导致ienumerable总是为空.
角度呼叫
$http.post(customer/DoSomething, {names: ["chris", "joe"]})
Run Code Online (Sandbox Code Playgroud)
方法
string DoSomething(Customer customer){...}
Run Code Online (Sandbox Code Playgroud)
模型
// populates IEnumerable
public class Customer
{
public IEnumerable<string> Names {get; set;}
}
// what I want to do but IEnumerable is always empty
public class Customer
{
private IEnumerable<string> _names;
public IEnumerable<string> Names
{
get
{
return _names ?? new List<string>();
}
set
{
_names = value;
}
}
}
Run Code Online (Sandbox Code Playgroud) .net ×3
angularjs ×3
c# ×3
javascript ×2
asp.net ×1
async-await ×1
asynchronous ×1
dictionary ×1
git ×1
linq ×1
node.js ×1
signalr ×1
task ×1