Angular 2 - 是否可以将我的路由存储在另一个文件中并将其导入app.ts文件中(因为随着时间的推移,路由将会建立)
这是我当前app.ts的一个例子.我基本上想将路由配置路由移动到另一个文件以使其更清洁:
import {Todo} from './components/todo/todo';
import {About} from './components/about/about';
import {AuthService} from './authService';
import {Component, View, bootstrap, bind, provide} from 'angular2/angular2';
import {Router, ROUTER_BINDINGS, RouterOutlet, RouteConfig, RouterLink, ROUTER_PROVIDERS, APP_BASE_HREF} from 'angular2/router';
import {Location, LocationStrategy, HashLocationStrategy} from 'angular2/router';
@Component({
selector: 'app'
})
@View({
template: `
<div class="container">
<nav>
<ul>
<li><a [router-link]="['/Home']">Todo</a></li>
<li><a [router-link]="['/About']">About</a></li>
</ul>
</nav>
<router-outlet></router-outlet>
</div>
`,
directives: [RouterOutlet, RouterLink]
})
@RouteConfig([
{ path: '/', redirectTo: '/home' },
{ path: '/home', component: Todo, as: 'Home' }, …Run Code Online (Sandbox Code Playgroud) 我正在从数据库中获取数据并通过将手动操作按钮列添加到 Ag-Grid 来填充它。现在,第一列由这些操作按钮组成,第二列包含 _id 我想隐藏第二列,但在 ag-grid 文档中,他们只提供了有关隐藏静态数据列的信息。这是我的具有列 def 的代码。
setMasterData (state, payload) {
if (!payload) {
state.tableData.rows = [];
} else {
// First column holds the buttons to delete the row item
let cols = [{
field: '',
headerName: 'Actions',
width: 200,
colId: 'params',
cellRendererFramework: 'gridEditButtons'
}];
cols = cols.concat(Object.keys(payload[0]).map(x => {
return {
field: x,
headerName: x.replace(/([A-Z])/g, ' $1').replace(/^./, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); })
};
}));
state.tableData.cols = cols;
state.tableData.rows = payload;
}
}
Run Code Online (Sandbox Code Playgroud)
如何隐藏操作列之后的下一列?
我刚刚开始学习角度2,虽然创建了一个小应用程序使用它但无法找到使用角度2模块,如角度2,路由器等,所以可以请一些请帮助下载和管理角度2模块使用亭子.
好的,所以我在这里阅读了很多帖子,我有点尴尬因为我认为我理解了基本的dplyr功能.
我不能group_by组成团体,我感到困惑.
我有数据框test.我想要的只是按变量分组ID,然后计算每组两个变量之间的相关性.
我不知道发生了什么,因为它没有分组,只有当我应该有127组和127个相关时才输出1个相关性.为什么?
什么test样子:
我写的:
library(dplyr)
library(magrittr)
test%>%
mutate(ID=as.character(ID))%>%
group_by(ID)%$%
cor(sulfate,nitrate,use="complete.obs")
Run Code Online (Sandbox Code Playgroud)
我得到了什么:[1] 0.0568084.
我正在尝试在我的 CNN 模型上应用转移学习,但出现以下错误。
model = model1(weights = "model1_weights", include_top=False)
Run Code Online (Sandbox Code Playgroud)
----
TypeError: __call__() takes exactly 2 arguments (1 given)
Run Code Online (Sandbox Code Playgroud)
谢谢
这是我试图解决的问题.鉴于像6928这样的数字:
difference between 6 and 9 is 3
difference between 9 and 2 is 7
difference between 2 and 8 is 6
Run Code Online (Sandbox Code Playgroud)
因此,简化形式为376.由于这不是两位数,我们重复这个过程:
difference between 3 and 7 is 4
difference between 7 and 6 is 1
Run Code Online (Sandbox Code Playgroud)
结果是41,这是一个两位数的数字,解决方案!
这是使用递归方法的尝试,但我希望以非递归方式执行此操作:
public static int twodigit(int value) {
while (value > 99)
value = reduce(value);
return value;
}
private static int reduce(int value) {
return (value<=9? 0:reduce(value/10)*10 + Math.abs(value/10%10-value%10));
}
Run Code Online (Sandbox Code Playgroud) 在过去的几个小时里,我一直在尝试用一根镜头从一根长串中踢出一些符号,但是我怎么也不知道如何删除它们.如果我去使用.replace()函数,它将是一个更丑陋的方法,因为符号的数量不止一个,并且函数变得过长而无法覆盖它们.任何替代方式删除它们将非常感激.
这是我试过的:
exmpstr = "Hi there Sam! Don't you know that Alex (the programmer) created something useful or & easy to control"
print(exmpstr.replace("'","").replace("(","").replace(")","").replace("&",""))
print(exmpstr.replace("['()&]","")) #I know it can't be any valid approach but I tried
Run Code Online (Sandbox Code Playgroud)
我想要踢出的是'()&这个字符串中的符号,而不是我尝试使用.replace()函数的方式.
我试图通过下面的代码解码这个json数据,但是它不起作用.
$data = 'VA_OnQueryData({"name":"John","id":"354902332592"});';
return json_decode($data);
Run Code Online (Sandbox Code Playgroud) angular ×2
python-3.x ×2
ag-grid ×1
ag-grid-ng2 ×1
bower ×1
dplyr ×1
java ×1
javascript ×1
jsondecoder ×1
keras ×1
php ×1
python ×1
r ×1
string ×1
symbols ×1
vue.js ×1
vuex ×1
yeoman ×1