惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Latest news
Latest news
T
The Exploit Database - CXSecurity.com
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
L
Lohrmann on Cybersecurity
aimingoo的专栏
aimingoo的专栏
B
Blog
T
Threat Research - Cisco Blogs
罗磊的独立博客
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Proofpoint News Feed
P
Palo Alto Networks Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
T
Tor Project blog
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
Recorded Future
Recorded Future
D
DataBreaches.Net
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
B
Blog RSS Feed
Scott Helme
Scott Helme
P
Proofpoint News Feed
V
Vulnerabilities – Threatpost
A
Arctic Wolf
Help Net Security
Help Net Security
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
AWS News Blog
AWS News Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Schneier on Security
Hacker News: Ask HN
Hacker News: Ask HN
N
Netflix TechBlog - Medium
L
LangChain Blog
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
M
MIT News - Artificial intelligence
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
W
WeLiveSecurity

博客园 - 新房客

iOS中判断Apple Pencil力度与手触摸 Electron,VUEJS3,Vite,TypesSript 开发环境配置 安卓2022.3.11环境配置 网上设置的跨域基本都失效了,新的设置方式 从模型坐标到屏幕坐标 群晖中使用Docker安装备份升级Gitlab vscode Typescript自动修复引入类时,引号设置 基于nodejs的阿里云DDNS服务,支持多网卡绑定 WebGL与Canvas的显存与内存使用分析 基于nodejs的游戏服务器 typescript 中 d.ts module 与 namespace 区别 使用vs code与microsoft edge调试webpack项目 解决Jenkins无法编译Egret5.0项目的问题 筛选git最后一次文件列表 推荐一个不错的plist拆解工具,untp - 新房客 - 博客园 vs code(egret wing) php配置与调试 关于 typings install 的使用 angular2 环境配置 html5 js跨域
angular 引入 component 报错
新房客 · 2016-09-27 · via 博客园 - 新房客

每天抽出一些时间学习 Angular2 ,并准备把手头上的项目移植为 Angular2 , 不过今天又遇到了一些小问题。

准备写一个导航类适于管理后台常见的右边导航,如博客园的这种:

!

使用 g generate component nav-left 建立了一个名为 nav-left 的导航组件。

这里需要检查app,modile.ts中是否已经有你新建的组件。一般会自动添加,如果不存在需要添加引用:

import { NavLeftComponent } from './nav-left/nav-left.component';

模块装饰器需要添加:

@NgModule({
declarations: [
NavLeftComponent,
]
})

并在 nav-left.component.ts 中新建了一个类,Item 用来保存菜单的项,代码如下:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-nav-left',
  templateUrl: './nav-left.component.html',
  styleUrls: ['./nav-left.component.css'],
})

export class NavLeftItem{
    name:string;
    path:string;
    data:any;
    active?:string="";
}

export class NavLeftComponent implements OnInit {

  constructor() { }
}

开开心心的运行查看报错结果^^~!

报错的信息忘截图了,大致的意思是找不到这个模块,或这个模块没办法解析。

这步骤花了好长时间,最终确定问题竟然有两处,也没继续深研,分别是:

1:需要单独创建数据类。把Item单独提取一个类。 最终结果如图:

2:我在组件中写了一些预定义的数据,如下:

  //这里需要注意变量顺序,我这里是错的,因为titleList中的其他变量引用还未定义。。。。
  public titleList :Array<{"name":string,"list":any}> =[
    {"name":"后台工具","list":this.adminTool},
    {"name":"运维工具","list":this.maintenanceTool},
    {"name":"运营工具","list":this.statisticalTool},
    {"name":"GM工具","list":this.gmlTool}
  ];

  /**
   * 后台工具
   */
  public adminTool:Array<NavLeftItem> = [
    {"name":"账号列表","path":"manage/index","data":null},
    {"name":"账号权限","path":"manage/index","data":null},
    {"name":"账号密码","path":"manage/index","data":null},
    {"name":"账号添加","path":"manage/index","data":null},
    {"name":"游戏列表","path":"manage/index","data":null},
    {"name":"渠道列表","path":"manage/index","data":null},
    {"name":"渠道添加","path":"manage/index","data":null},
    {"name":"操作日志","path":"manage/index","data":null},
    {"name":"操作详情","path":"manage/index","data":null},
  ];
  /**
   * 运维工具
   */
  public maintenanceTool:Array<NavLeftItem> = [
    {"name":"Log服务器列表","path":"manage/index","data":null},
    {"name":"Log服务器添加","path":"manage/index","data":null},
    {"name":"Log入口服务列表","path":"manage/index","data":null},
    {"name":"Log入口服务配置","path":"manage/index","data":null},
    {"name":"Log服务器状态","path":"manage/index","data":null},
    {"name":"Log服务器日志","path":"manage/index","data":null},
    {"name":"Log服务器Qps统计","path":"manage/index","data":null},
    {"name":"Log服务器数据库信息","path":"manage/index","data":null},
    {"name":"Log服务器合并","path":"manage/index","data":null},
  ];

一直编译不通过,最终确定问题是顺序问题。。。很尴尬。修改顺序为:

先定义:titleList 然后定义其他几项。

问题解决。~~~~~~~~