Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 通过离子工厂的离子导航_Angular_Ionic Framework_Navigation - Fatal编程技术网

Angular 通过离子工厂的离子导航

Angular 通过离子工厂的离子导航,angular,ionic-framework,navigation,Angular,Ionic Framework,Navigation,我想用这样的ion fab让我的ion tab条更漂亮: 因此,我添加了一个SVG和一个ion fab来实现这一点,但当我想使用ion fab进行导航时,它没有任何行为(甚至在控制台中),对于ion选项卡按钮,它工作正常 这是我的密码: tabs.page.html 我的tabs.page.ts 从'@angular/core'导入{Component,OnInit}; 从'@angular/Router'导入{Router}; @组成部分({ 选择器:“应用程序选项卡”, templat

我想用这样的ion fab让我的ion tab条更漂亮:

因此,我添加了一个SVG和一个ion fab来实现这一点,但当我想使用ion fab进行导航时,它没有任何行为(甚至在控制台中),对于ion选项卡按钮,它工作正常

这是我的密码:

tabs.page.html


我的tabs.page.ts

从'@angular/core'导入{Component,OnInit};
从'@angular/Router'导入{Router};
@组成部分({
选择器:“应用程序选项卡”,
templateUrl:'./tabs.page.html',
样式URL:['./tabs.page.scss'],
})
导出类选项卡页实现OnInit{
构造函数(专用路由器:路由器){}
恩戈尼尼特(){
}
添加食物(){
this.router.navigateByUrl['/addFood'];
}
}
和我的选项卡-routing.module.ts

从'@angular/core'导入{NgModule};
从'@angular/router'导入{Routes,RouterModule};
从“./tabs.page”导入{TabsPage};
常数路由:路由=[
{
路径:“”,
组件:TabsPage,
儿童:[
{
路径:'板',
加载子项:()=>
导入('../boards/boards.module')。然后((m)=>m.BoardsPageModule),
},
{
路径:“搜索”,
加载子项:()=>
导入('../search/search.module')。然后(
(m) =>m.SearchPageModule
),
},
{
路径:“通知”,
加载子项:()=>
导入('../notifications/notifications.module')。然后(
(m) =>m.NotificationsPageModule
),
},
{
路径:“配置文件”,
加载子项:()=>
导入('../profile/profile.module')。然后((m)=>m.ProfilePageModule),
},
{
路径:“添加食物”,
加载子项:()=>
导入('../addfood/addfood.module')。然后((m)=>m.AddFoodPageModule),
},
{
路径:“”,
重定向至:“董事会”,
路径匹配:“已满”,
},
],
},
];
@NGD模块({
导入:[RouterModule.forChild(路由)],
导出:[路由模块],
})
导出类TabsAgeoutingModule{}
如果有人能帮助我,我将不胜感激


谢谢。

也许这只是个打字错误。您忘记了navigatebyUrl调用的括号:
navigatebyUrl([…])
Try:
this.router.navigate(['/addFood'])@DavidB。当我在navigateByUrl函数中使用方括号时,VSCode抛出一个错误,类型为“string[]”的参数不能分配给类型为“string | UrlTree”的参数。类型“string[]”不可分配给类型“string”。ts(2345)@NajamUsSaqib此解决方案还在控制台中引发错误。错误:未捕获(承诺中):错误:无法匹配任何路由。URL段:“addFood”错误:无法匹配任何路由。URL段:“addFood”可能是tabs-routing.module.ts中的路由错误?您可以尝试:
this.router.navigate(['tabs/addFood'])