我一直在学习Angular2.在nodejs lite-server上运行时,路由工作正常.我可以转到主(localhost:3000)页面并浏览应用程序.我也可以输入localhost:3000/employee,它将转到请求的页面.
该应用程序最终将存在于Windows IIS 7.5服务器上.如果我从主页面(localhost:2500)开始,路由工作正常,我可以在没有任何问题的情况下通过应用程序.我遇到问题的地方是尝试直接转到主登陆页面以外的页面(localhost:2500/employee).我收到HTTP错误404.0.
这是我的app.component文件,用于处理路由.
import { Component } from '@angular/core';
import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from '@angular/router-deprecated';
import { HTTP_PROVIDERS } from '@angular/http';
import { UserService } from './services/users/user.service';
import { LogonComponent } from './components/logon/logon.component';
import { EmployeeComponent } from './components/employee/employee.component';
@Component({
selector : 'opi-app',
templateUrl : 'app/app.component.html',
directives: [ROUTER_DIRECTIVES],
providers: [ROUTER_PROVIDERS, UserService, HTTP_PROVIDERS]
})
@RouteConfig([
{
path: '/',
name: 'Logon',
component: LogonComponent,
useAsDefault: true
},
{
path: '/employee',
name: 'Employee',
component: EmployeeComponent
}
])
export class …Run Code Online (Sandbox Code Playgroud) 我在Angular 2应用程序中有以下JSON对象,并想知道在typescript中声明它的正确方法是什么.
data = [
{
'id':1,
'title':'something'
'node': [
{
'id':1,
'title':'something'
'node': []
}
]
},
{
'id':2,
'title':'something'
'node': [
{
'id':1,
'title':'something'
'node': []
}
]
}
]
Run Code Online (Sandbox Code Playgroud) 我有一个JSON对象,它有几个级别的嵌套对象以及嵌套的对象数组.我想知道如何使用Angular2和*ngFor来遍历对象并最终打印出来.第一个*ngFor可以工作,但下一个*ngFor给我和错误说Cannot read property nodes of undefined
当前的HTML代码
<div class="col-md-3">
<div>
<ol>
<li *ngFor="let item of videoList" > {{item.title}} </li>
<ol>
<li *ngFor="let subItem of videoList.item.nodes"> {{subItem.title}} </li>
</ol>
</ol>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
JSON对象
videoList = [
{
'id':1,
'title':'Lower Extremities',
'nodes':[
{
'id':11,
'title':'Cast Receive',
'nodes':[
{
'id':111,
'title':'Video 1',
'nodes':[
{
'id':1111,
'title':'Working',
'nodes':[]
},
{
'id':1112,
'title':'Stacking',
'nodes':[]
},
]
},
{
'id':112,
'title':'Video 2',
'nodes':[]
},
{
'id':113,
'title':'Video 3',
'nodes':[]
}
]
},
{
'id':12,
'title':'Cast …Run Code Online (Sandbox Code Playgroud)
我有一个标签栏视图控制器,有四个可能的视图控制器.所有其他视图都有关系的主标签栏视图也有一个导航栏,我可以双击并更改故事板中的标题.我需要知道的是如何根据选定的标签栏项更改此导航项的标题.
例如,我将有四个选项卡.1是"Bills",2是"Groceries",3是"Gas",4是"Personal".如果选中"票据选项卡",我希望我的视图标题为Bills,依此类推.
编辑:希望这将澄清我想要完成的事情.
我希望能够在右侧四个表视图的顶部更改导航栏的标题.标签栏控制器是我唯一可以双击并在故事板上更改磁贴的地方.我希望根据从选项卡栏中选择的表视图来更改标题.