我正在使用Typescript和Visual Studio 2015与Resharper 9.让我说我想将我的角度控制器方法从activate重命名为init.会发生什么事情,Resharper开始搜索libs中的所有可疑引用,如angular.js,jquery.js等.它还会扫描所有剃刀视图以查找可能的用法.有时这个操作非常慢并且不合逻辑因为我永远不想在angular.js库中重命名.如何从扫描中跳过这些文件?
今天我使用Object.keys收到错误,因为我意外地传递了非对象值,如下所示:
var filter = true;
var filterKeys = Object.keys(filter);
Run Code Online (Sandbox Code Playgroud)
在Chrome中这很好用,但是在IE 11中我得到了异常并且在调试后发现在IE 11中Object.keys抛出异常Object.keys:参数不是Object.
在这种情况下,IE11表现得更好,因为值true确实无效,但chrome返回空数组.Object.keys是ECMAScript标准,如果你看http://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.14,它说:
所以有人知道为什么谷歌Chrome实现的行为与ECMAScript规范标准不同,因为我一直认为所有现代浏览器都应该以相同的方式实现ECMAScript.
我正在使用角度通用,但找不到用于仅对某些页面(如主页)使用服务器端渲染并以标准角度方式渲染所有其他路线的选项。我不想在不需要SEO的私有页面上使用服务器端渲染。我可以这样配置快速路由
// send all requests to Angular Universal
// if you want Express to handle certain routes (ex. for an API) make sure you adjust this
app.get('/', ngApp);
app.get('/home', ngApp);
app.get('/about', ngApp);
Run Code Online (Sandbox Code Playgroud)
理想情况下,我完全不需要了解NodeJ,并使用有如serverSide这样的属性在有角路由配置中对其进行配置:true
const appRoutes: Routes = [
//public route, I want server rendering for SEO
{ path: 'home', component: HomeComponent, serverSide: true },
//private user profile page, SEO is not needed
{ path: 'user/profile/:id', component: UserProfileComponent },
];
Run Code Online (Sandbox Code Playgroud) 我在搜索设计时如何实现大量计算,以便代码看起来干净并且可以进行单元测试.这就是我现在这样做的方式.
我有块General,MainEngine,AuxEngine,Boilers,WaterBoilers等形式.每个街区都有很多属性.现在我的计算类看起来像这样.
我在块之间使用部分类来分别计算逻辑
/// <summary>
/// My result class wich fill CalculationResult
/// </summary>
public partial class CalculateBlocks
{
private readonly IClassificatoryService _classificatoryService;
private readonly IReportService _reportService;
public CalculationResult Result = new CalculationResult();
/// <summary>
/// Ctor with DI
/// </summary>
public CalculateBlocks(IClassificatoryService classificatoryService,IReportService reportService)
{
_classificatoryService = classificatoryService;
_reportService = reportService;
}
public void Calculate()
{
CalculateGeneral();
CalculateMainEngine();
//and a lot more blocks
}
}
public partial class CalculateBlocks
{
private void CalculateGeneral()
{
Result.General.TotalReports = 2 + 2; …Run Code Online (Sandbox Code Playgroud)