首先,我是使用nodejs,angular2和typescript进行此类编程的完全初学者.基本上我开始阅读https://angular.io/docs/ts/latest/guide/forms.html和https://angular.io/docs/ts/latest/guide/router.html#!#base-href使用新页面扩展我的应用程序.我使用mdl在我的应用程序上使用材质组件.
角度2似乎手动重新加载和路由不同所以我得到以下问题:
我尝试了解发生了什么,有人可以解释我在angular2中重新加载和路由之间的区别,以及我如何适应路由到重新加载行为的处理?
更新#1:
index.html:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Title</title>
<script defer src="/assets/js/material.min.js"></script>
<link rel="stylesheet" href="/assets/css/font-awesome.min.css">
<link rel="stylesheet" href="/assets/css/material.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root><md-spinner></md-spinner></app-root>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './pages/layout/app.component';
import { HomeComponent } from './pages/home/app.component'; …Run Code Online (Sandbox Code Playgroud) 我正在学习Angular2但是我对使用Angular2和MDL有疑问.为什么MDL导航栏不能与Angular2一起使用?当我使用带有标题和抽屉的导航栏时,抽屉不工作,所以我无法点击它,我看不到抽屉的图标.还有另一个问题:文本字段也无法正常工作.我想使用mdl-textfield - expandable(搜索)但是当我点击这个搜索字段时它没有扩展.但是,没有Angular2它工作正常.
UPDATE
<div class="demo-layout-waterfall mdl-layout mdl-js-layout">
<header class="mdl-layout__header mdl-layout__header--waterfall">
<!-- Top row, always visible -->
<div class="mdl-layout__header-row">
<!-- Title -->
<span class="mdl-layout-title">Title</span>
<div class="mdl-layout-spacer"></div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--expandable
mdl-textfield--floating-label mdl-textfield--align-right">
<label class="mdl-button mdl-js-button mdl-button--icon" for="waterfall-exp">
<i class="material-icons">search</i>
</label>
<div class="mdl-textfield__expandable-holder">
<input class="mdl-textfield__input" type="text" name="sample" id="waterfall-exp">
</div>
</div>
</div>
<!-- Bottom row, not visible on scroll -->
<div class="mdl-layout__header-row">
<div class="mdl-layout-spacer"></div>
<!-- Navigation -->
<nav class="mdl-navigation">
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a> …Run Code Online (Sandbox Code Playgroud)