我使用angular-cli在angular6的全新安装上出现以下错误.
未捕获错误:模板解析错误:'router-outlet'不是已知元素:1.如果'router-outlet'是Angular组件,则验证它是否是此模块的一部分.
我遵循了这个指南:https://medium.com/@meemo_86/good-article-beeman-490eaf1399a
然后我跟进了那篇文章的评论,该评论说要用<router-outlet></router-outlet>而不是<ng-content></ng-content>.
我做了那些更正,然后我读了https://angular.io/tutorial/toh-pt5,并做了那里所说的.
所以现在我有一个AppRoutingModule,我在app.module.ts中导入该模块,在那里我也修改路由并添加RouterModule.forRoot(appRoutes)到导入.
但我不能让这个错误消失.我究竟做错了什么?当我添加<router-outler></router-outlet>我layout.component.htm的应用程序时,应用程序会中断.我也在这里搜索了这个主题并尝试了一些改变,但似乎没有任何效果.
完整的源代码在这里:
我试图创建一个名为theUser的全局变量,如果登录则包含userinfo.
我试过把它放在我的SPA php文件中:
app.value('theUser', '<?php echo Auth::user(); ?>');
Run Code Online (Sandbox Code Playgroud)
它只能在刷新页面后才能工作.(登录通过angularjs逻辑+ $ http请求到auth/login,如果登录则返回userinfo)
在我的角度认证应用程序中,我做到了这一点:
var login = $http.post("auth/login", sanitizeCredentials(credentials)).success(function(data) {
theUser = data;
$rootScope.theUser = theUser;
});
Run Code Online (Sandbox Code Playgroud)
这样可行,但仅在用户登录时才有效.如果我刷新,则用户为空.我不能让这两个解决方案一起工作.我可能需要另一种方法.
我想要的只是一个用户变量,我可以从我的应用程序中的任何位置访问,如果用户登录,或者之前已登录,则设置.使用Laravel 5.1.
这是我的auth app服务js:http://pastebin.com/HcdLaZcD
任何人都可以解雇我吗?谢谢.
我有一个恼人的问题,使用最新的OctoberCMS构建(318),它试图将错误的数据保存到数据透视表而不是模型表.
我有一个模型企业,和一个模型Openinghours:
型号商家:
`public $table = 'ekstremedia_emcityportal_businesses';`
`public $belongsToMany = [
'openinghours' => [
'Ekstremedia\EmCityportal\Models\Openinghours',
'table' => 'ekstremedia_emcityportal_ohb',
'order' => 'week_day',
'week_day' => 'week_day',
'name' => 'week_day',
]
];`
Run Code Online (Sandbox Code Playgroud)
ekstremedia_emcityportal_ohb是带business_id和的数据透视表openinghours_id
和Openinghours的模型:
public $table = 'ekstremedia_emcityportal_openinghours';
public $belongsToMany = [
'businesses' => ['Ekstremedia\EmCityportal\Models\Business',
'table' => 'ekstremedia_emcityportal_businesses',
'order' => 'created_at desc'
]
];
Run Code Online (Sandbox Code Playgroud)
在业务控制器中,field.yaml我已经完成了这项工作,为业务增加营业时间:
openinghours:
type: repeater
label: 'Åpningstider'
tab: 'Åpningstider'
form:
fields:
week_day:
label: Dag
oc.commentPosition: ''
options:
1: Måndag
2: …Run Code Online (Sandbox Code Playgroud)