小编Bau*_*umi的帖子

Ionic 2将选项卡NavParams传递给选项卡

我开始使用Ionic 2创建我的第一个应用程序,并通过大量的试验和错误已达到一个点,没有数量的谷歌搜索可以找到任何帮助.

我正在尝试将一些NavParams传递给选项卡.NavParams在父标签页中可用:

@Page({
    templateUrl: 'build/pages/tabs/tabs.html'
})
export class TabsPage {
  constructor(params: NavParams) {

      this.params = params;
      console.log(this.params); // returns NavParams {data: Object}

      // this tells the tabs component which Pages should be each tab's root Page
      this.tab1Root = Tab1;
      this.tab2Root = Tab2;
      this.tab3Root = Tab3;
    }
}
Run Code Online (Sandbox Code Playgroud)

但我似乎无法在选项卡本身中获取NavParams:

@Page({
    templateUrl: 'build/pages/tab1/tab1.html'
})
export class Tab1 {
    constructor(nav: NavController, params: NavParams, platform: Platform) {
        this.nav = nav;
        this.params = params;
        this.platform = platform;

        console.log(this.params); // returns NavParams {data: null}
    } …
Run Code Online (Sandbox Code Playgroud)

ionic-framework ionic2

41
推荐指数
3
解决办法
4万
查看次数

模块'AppModule'导入的意外值'MyCustomModule'

我正在尝试将我的angular2自定义库之一迁移到RC.6 + Webpack.我的目录结构是:

- src - source TS files
- lib - transpiled JS files + definition files
- dev - development app to test if it works / looks ok.
- myCustomLib.js - barrel
- myCustomLib.d.ts
Run Code Online (Sandbox Code Playgroud)

dev文件夹内尝试运行应用程序.我引导我的模块:

app.module.ts

import { BrowserModule }                from "@angular/platform-browser";
import { NgModule }                     from "@angular/core";
import { AppComponent }                 from "./app.component";
import { MyCustomModule }               from "../../myCustomLib";

@NgModule({
    imports: [
        BrowserModule,
        MyCustomModule
    ],
    declarations: [ AppComponent ],
    bootstrap: [ AppComponent ]
}) …
Run Code Online (Sandbox Code Playgroud)

webpack angular2-modules angular

27
推荐指数
1
解决办法
1万
查看次数

Angular2 Router v3,导航到不同级别:TypeError:无法读取null的属性'_routeConfig'

我正在使用新的Router v3.0.0-alpha.3.想象一下我的路线如下:

                              App
                              /\
                             /  \
                       Settings  Main
                          / \        
                         /   \      
                       User  Account
Run Code Online (Sandbox Code Playgroud)

从用户组件的角度来看,我想导航到主要组件.如果我导航到设置级别中的任何组件它工作正常,但当我尝试导航到其他级别时,我收到一个错误:

EXCEPTION: Error: Uncaught (in promise): TypeError: Cannot read property '_routeConfig' of null
Run Code Online (Sandbox Code Playgroud)

我使用routerLink指令naviagate:

[routerLink]="['/main']"           <- doesn't work
[routerLink]="['/settings']"       <- works
[routerLink]="['/settings/user']"  <- works
Run Code Online (Sandbox Code Playgroud)

这似乎是一个全球性问题.我只能在同一级别内导航.任何想法我怎么能绕过它?

我的路由传递给bootstrap:

export const routes: RouterConfig = [
    ...MainRoutes,
    ...SettingsRoutes
];

export const APP_ROUTER_PROVIDERS = [
    provideRouter(routes)
];
Run Code Online (Sandbox Code Playgroud)

main.routes.ts:

export const MainRoutes: RouterConfig = [{
    path: '/main',
    component: SettingsComponent
}];
Run Code Online (Sandbox Code Playgroud)

settings.routes.ts:

export const SettingsRoutes: RouterConfig = [{
    path: '/settings',
    component: SettingsComponent,
    children: …
Run Code Online (Sandbox Code Playgroud)

angular2-routing angular

10
推荐指数
1
解决办法
1859
查看次数

Svg 缩放到特定矩形

我有带有多个分组元素的 SVG。我要做的就是缩放到特定组。

我已经得到了正确的答案{top, left, width, height},我想缩放到(更改viewBox我的 SVG 的属性)。

有什么简单的方法可以计算 的正确值吗viewBox

javascript svg viewbox

1
推荐指数
1
解决办法
3249
查看次数