ngx-admin/articles/013-create-new-page/index.html
2016-05-25 14:35:57 +03:00

105 lines
No EOL
6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width">
<meta name="keywords" content="admin,dashboard,template,angular,bootstrap,blur,panel,html,css,javascript">
<title>BlurAdmin documentation - Create New Page</title>
<link rel="alternate" href="http://localhost:8080/feed.xml" type="application/rss+xml" title="">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900italic,900|Anonymous+Pro:400,700,400italic,700italic&amp;subset=latin,greek,greek-ext,vietnamese,cyrillic-ext,latin-ext,cyrillic">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.0/gh-fork-ribbon.min.css">
<link rel="stylesheet" href="/ng2-admin/css/main.css">
<link rel="shortcut icon" href="/ng2-admin/images/favicon.png">
</head>
<body>
<div class="container">
<div class="nav-main">
<div class="wrap"><a href="/ng2-admin/" class="nav-home"><img src="/ng2-admin/images/logo.png" width="24" height="24" class="nav-logo">&nbsp;<span class="blur-label">ng2-</span>admin</a>
<ul class="nav-site nav-site-internal">
<li><a href="/ng2-admin/">Home</a></li>
<li><a href="/ng2-admin/articles/001-getting-started/" class="active">Docs</a></li>
</ul><span class="nav-docs-right">Need some help? Let us know! <a href="mailto:contact@akveo.com">contact@akveo.com</a></span>
</div>
</div>
<section class="content wrap documentationContent">
<div class="nav-docs">
<div class="nav-docs section">
<h3>Quick Start</h3>
<ul>
<li><a href="/ng2-admin/articles/001-getting-started/">Getting Started</a></li>
<li><a href="/ng2-admin/articles/002-installation-guidelines/">Installation Guidelines</a></li>
</ul>
</div>
<div class="nav-docs section">
<h3>Customization</h3>
<ul>
<li><a href="/ng2-admin/articles/011-changing-color-scheme/">Changing Color Scheme</a></li>
<li><a href="/ng2-admin/articles/014-switch-to-blur-theme/">Enabling blur theme</a></li>
<li><a href="/ng2-admin/articles/012-project-structure/">Project Structure</a></li>
<li><a href="/ng2-admin/articles/013-create-new-page/" class="active">Create New Page</a></li>
</ul>
</div>
<div class="nav-docs section">
<h3>Components</h3>
<ul>
<li><a href="/ng2-admin/articles/016-spinner/">Theme Spinner</a></li>
<li><a href="/ng2-admin/articles/015-sidebar/">Sidebar</a></li>
</ul>
</div>
</div>
<div class="inner-content">
<h1>Create New Page</h1>
<div class="subHeader"></div><p>ng2-admin uses <a href="https://angular.io/docs/ts/latest/guide/router-deprecated.html">Angular Router</a> for navigation.
Currently this version of the router is deprecated and we are going to move on to a new version once its&nbsp;stable.</p>
<p>We strongly recommend to follow pages structure in your application.
If it doesnt fit your needs please create a GitHub issue and tell us why. We would be glad to&nbsp;discuss. </p>
<p>Basically any page is just a usual Angular 2 Component with some routes defined for&nbsp;it.</p>
<h2 id="page-creation-example">Page creation&nbsp;example</h2>
<p>1) Lets assume we want to create a blank page with title My New Page
<br><br></p>
<p>2) Lets Create a new directory to contain our new page inside of <code>src/app/pages</code>. Lets call this directory <code>new</code>.
<br><br></p>
<p>3) Then lets create blank angular component to contain our page called new.component.module.js inside of <code>src/app/pages/new</code>:</p>
<pre><code class="lang-javascript"><span class="keyword">import</span> {Component} <span class="keyword">from</span> <span class="string">'@angular/core'</span>;
@Component({
selector: <span class="string">'new'</span>,
pipes: [],
providers: [],
styles: [],
template: <span class="string">`&lt;strong&gt;My page content here&lt;/strong&gt;`</span>
})
<span class="keyword">export</span> <span class="class"><span class="keyword">class</span> <span class="title">New</span> </span>{
<span class="keyword">constructor</span>() {
}
}
</code></pre>
<p>This will create a simple Angular 2 component, for more detail please check out <a href="https://angular.io/docs/ts/latest/guide/displaying-data.html">official Angular 2 documentation</a>.
<br><br></p>
<p>4) Last thing we need to do is to define a Router configuration in a parent component, in our case in Pages component <code>src/app/pages/pages.component.ts</code>:</p>
<pre><code class="lang-javascript">@RouteConfig([
<span class="comment">// ... some routes here</span>
{
name: <span class="string">'New'</span>,
component: New,
path: <span class="string">'/new'</span>,
}
])
<span class="keyword">export</span> <span class="class"><span class="keyword">class</span> <span class="title">Pages</span> </span>{
}
</code></pre>
<p><br><br></p>
<p>And thats it! now your page should be available by the following url <a href="http://localhost:3000/#/pages/new">http://localhost:3000/#/pages/new</a>.
If you want to add a link to your page into Sidebar, please look at the <a href="/ng2-admin/articles/015-sidebar/">following article</a>.</p>
</div>
</section>
<footer class="wrap">
<div class="left">Powered by Angular 2, Bootstrap 4, Webpack and many more...</div>
<div class="right">© 20152016 Akveo LLC<br />Documentation licensed under <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>.</div>
</footer>
</div><a href="https://github.com/akveo/ng2-admin" title="Star &amp; Fork on GitHub" class="github-fork-ribbon"></a>
</body>
</html>