我正在使用Angular Meteor 2创建一个简单的UI.
1)我有一个顶部导航栏组件,其中有一个"注销"按钮.
2)点击"退出"按钮后,它会重定向到"登录".
3)然后我在控制台中看到此错误:EXCEPTION: Attempt to use a destroyed view: detectChanges
例外:
EXCEPTION: Attempt to use a destroyed view: detectChanges
browser_adapter.js:77 EXCEPTION: Attempt to use a destroyed view: detectChangesBrowserDomAdapter.logError @ browser_adapter.js:77BrowserDomAdapter.logGroup @ browser_adapter.js:87ExceptionHandler.call @ exception_handler.js:57(anonymous function) @ application_ref.js:265schedulerFn @ async.js:123SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:112onError @ ng_zone.js:120onHandleError @ ng_zone_impl.js:66ZoneDelegate.handleError @ angular2-polyfills.js:394Zone.runTask @ angular2-polyfills.js:323ZoneTask.invoke @ angular2-polyfills.js:490
browser_adapter.js:77 STACKTRACE:BrowserDomAdapter.logError @ browser_adapter.js:77ExceptionHandler.call @ exception_handler.js:59(anonymous function) @ application_ref.js:265schedulerFn @ async.js:123SafeSubscriber.__tryOrUnsub …
Run Code Online (Sandbox Code Playgroud) 我正在使用Angular-Meteor框架构建一个Angular 2应用程序.
我想实现快速和一致的索引谷歌和其他搜索引擎,让Facebook的分享者和其他刮削器生成我的JS生成内容的预览.
通常,SPA使用PhantomJS呈现页面服务器端并将静态HTML发送到客户端.
当然,我可以生成PhantomJS自己,当我拦截_escaped_fragment_或当我看到谷歌或刮刀用户代理,但我总是经历了内存泄漏,并直接与大流量的网站产卵PhantomJS当孤儿幻影情况下(我用的NodeJS和这个模块).
对于Angular 1应用程序,我曾经使用像Angular-SEO这样的角度模块来解决这个问题,但似乎很难将这样的模块转换为角度2.
我还没有找到任何合适的Angular 2模块.我应该自己构建它,还是有任何其他好方法来实现这一点?
我正在创建一个angular2-meteor应用程序。
export const routes: Route[] = [{
path: '',
redirectTo: "login",
pathMatch: "full"
},
{
path: 'login',
component: LoginComponent
},
{
path: 'csvtemplate',
component: TemplateComponent,
canActivate: ['canActivateForLoggedIn'],
children: [{
path: '',
redirectTo: 'dashboard' <----how to add condition for multiple path
},
{
path:'dashboard',
component: DashboardComponent
},
{
path: 'csvtimeline/:month/:year',
component: CsvTimelineComponent
}, {
path: 'csvjson',
component: CsvJsonComponent
}]
}];
Run Code Online (Sandbox Code Playgroud)
当我使用LoginComponent登录到我的应用程序时,它将转到具有三个子组件的TemplateComponent
现在,默认情况下,我将redirectTo设置为我的仪表板组件。但是我想根据登录用户配置文件重定向到csvjson组件或csvtimeline组件,以代替此重定向。
假设
如果登录用户是“管理员”,则应将其重定向到->仪表板组件
如果登录用户是“来宾”,则应该将其重定向到-> csvjson组件
我知道我们可以在仪表板组件的ngOnInit()中进行重定向。
if (this.user && this.user.profile.role == 'Guest') {
this._router.navigate(['csvtemplate/csvjson']);
}
Run Code Online (Sandbox Code Playgroud)
但是我正在寻找更好的选择,因此我不必每次都打开仪表板组件,它将直接转到csvjson组件。
Newb to Angular 2.
如何在我的应用中加入Google字体.应用结构是
客户端
| --app.ts
| --main.ts
| --index.html
IndexFile.html
<head></head>
<body style="font-family: 'Montserrat', sans-serif;">
<div class="container-fluid">
<app-start>Loading...</app-start>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
头标记中包含的链接
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
Run Code Online (Sandbox Code Playgroud)
但是没有发生任何影响,还在客户端文件夹(font.js)中创建了一个JS文件并插入了代码
Meteor.startup(function() {
WebFontConfig = {
google: { families: [ 'Montserrat::latin' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
})
Run Code Online (Sandbox Code Playgroud)
但没有效果.
在Angular 2 + Meteor应用程序中包含此字体的正确方法
当我在angular2-meteor项目中使用Collection2时,来自demo的这些代码总是在终端中给我警告:
返回表达式中不存在最常见的类型.
我该如何改进代码?谢谢
{
createdAt: {
type: Date,
autoValue: function() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return {$setOnInsert: new Date()};
} else {
this.unset();
}
}
}
}
Run Code Online (Sandbox Code Playgroud) meteor typescript meteor-collection2 angular2-meteor angular
我正在Angular2-Meteor项目上,正在得到这个
“日期”类型的参数不能分配给“字符串”类型的参数。
当我编写此函数以设置日期值时出错。
start: startOfDay(new Date(attendance.dayAt)),
Run Code Online (Sandbox Code Playgroud)
我尝试将类型设置为日期,但无法正常工作,如何解决此错误?
我刚刚浏览了Meteor Angular 2教程.在第6步,我随机尝试了"meteor update",这使我的样本崩溃了.更新工作,服务器正在启动.但是,浏览器屏幕现在保持为空,并且在控制台中出现错误.由于我是流星的新手,我无法找出原因?
在浏览器中重新加载最终会在控制台中显示以下错误消息:
Uncaught SyntaxError: Unexpected token <
Uncaught (in promise) Uncaught SyntaxError: Unexpected token <
Evaluating http://localhost:3000/client/app.js
Error loading http://localhost:3000/client/app.js
Run Code Online (Sandbox Code Playgroud)
更新命令控制台输出:
meteor update
This project is already at Meteor 1.2.1, the latest release.
Changes to your project's package version selections from updating package
versions:
barbatus:angular2 upgraded from 0.6.6 to 0.7.3
barbatus:ng2-compilers upgraded from 0.1.0 to 0.1.1
barbatus:ts-compilers upgraded from 0.1.8 to 0.1.9_5
barbatus:typescript upgraded from 0.1.3 to 0.1.3_3
urigo:angular2-meteor upgraded from 0.2.5 to 0.3.5
Run Code Online (Sandbox Code Playgroud)
重启流星:
meteor
=> …
Run Code Online (Sandbox Code Playgroud) 我正在制作一个angular2-meteor
基于Meteor v1.4
和的应用程序Angular2 rc-5
.到目前为止还不错,但我需要将它与我的Firebase数据库集成,但我在下面得到了例外(我正在Chrome上运行该应用程序).似乎所有我的打字稿都没问题,我没有得到任何错误,我的Meteor应用程序正常加载,我按照安装和设置教程直到第4步结束.(但是因为我使用Meteor,我没有使用角度-cli创建项目),任何想法如何解决这个问题?谢谢
EXCEPTION: Error: This operation is not supported in the environment this application is running on.
"location.protocol" must be http or https and web storage must be enabled.
BrowserDomAdapter.logError @ browser_adapter.js:84
BrowserDomAdapter.logGroup @ browser_adapter.js:94
ExceptionHandler.call @ exception_handler.js:65
next @ application_ref.js:348
schedulerFn @ async.js:89
SafeSubscriber.__tryOrUnsub @ Subscriber.js:225
SafeSubscriber.next @ Subscriber.js:174
Subscriber._next @ Subscriber.js:124
Subscriber.next @ Subscriber.js:88
Subject._finalNext @ Subject.js:128
Subject._next @ Subject.js:120
Subject.next @ Subject.js:77
EventEmitter.emit @ async.js:77
onError @ ng_zone.js:124
onHandleError @ …
Run Code Online (Sandbox Code Playgroud) Angular-Meteor是否已准备好投入生产?有没有人使用Angular2-Meteor堆栈成功构建和部署工作解决方案?
我想通过以下方式更新流星中的电子邮件地址:
Meteor.users.update(this._id, {$set: {"emails[0].address": "deleted_" + preEmail }});
Run Code Online (Sandbox Code Playgroud)
但是,而不是更新email数组,先添加0参数,然后添加address,然后创建一个新字段,例如emails [0]然后address。有趣的是,在另一个.js文件中它可以正常工作!
我正在创建一个 Angular2-Meteor 应用程序,从社交教程开始。我正在尝试使用 alanning:roles 和 matb33:collection-hooks 实现用户角色。该解决方案与此处提出的解决方案类似。唯一的区别是 Angular 2 需要角色和 Collection-Hooks 的打字稿定义。我找到了meteor-typescript-libs,它有一个似乎有效的角色定义。然而,我发现的唯一的 collection-hooks 资源是 typed-meteor-collection-hooks。我尝试通过将文件复制/粘贴到我的项目中来引用index.d.ts,但仍然收到以下错误:
server/imports/accounts.ts (30, 14): 类型“Collection < User >”上不存在属性“after”。
在下面一行:
Meteor.users.after.insert(function (userId, doc) {
if (doc.profile.type === "basic") {
Roles.addUsersToRoles(doc._id, [ROLES.Basic])
} else if (doc.profile.type === "admin") {
Roles.addUsersToRoles(doc._id, [ROLES.Admin])
} else if (doc.profile.type === "manager") {
Roles.addUsersToRoles(doc._id, [ROLES.Manager])
}});
Run Code Online (Sandbox Code Playgroud)
我是打字稿新手,我不清楚应该如何实现 Meteor 包的类型定义。显然,我的做法是错误的。有人对 Meteor-Angular2 中的角色和收集挂钩有任何经验吗?
更新:尽管出现错误,但似乎 Meteor.users.after.insert() 代码在插入用户后正在执行。我正在继续开发,但希望有一个消除错误的解决方案。
我使用alanning:role
了流星包,角色工作正常,但问题是我收到了警告"Cannot find name 'Roles"
.
请帮我解决这个问题.我到处搜索过它.
有些人喜欢导入它 "import { Roles } from 'alanning:roles';"
我也尝试了这个,但仍然有错误...请帮助我,请不要像"问题"那样提交.我过去两天都在搜索这个问题,但是我没有回答,请给我任何帮助,或者请提前解决这个问题.
这是我的问题:
我想使用simple-schema的强大功能来检查我对以下模式的插入:
let UprocSchema = new SimpleSchema({
"name": { type : String, label: "Nom Uproc" },
"label": { type : String, label: "Libellé Uproc" },
"status": { type : String, label: "Status UPR" }
});
Run Code Online (Sandbox Code Playgroud)
出于某种原因,我忽略了,即使SimpleSchema似乎很好地实现了,我也不能在Mongo.Collection上使用attachSchema属性.
这是我的代码:
let repo_collection = new Mongo.Collection('repository');
export const Repository = new MongoObservable.Collection<Uproc>('repo_collection');
repo_collection.attachSchema( UprocSchema );
Run Code Online (Sandbox Code Playgroud)
这是我的错误消息:
"Collection <{}>"类型中不存在属性"attachSchema".
TypeError:repo_collection.attachSchema不是函数
angular2-meteor ×13
angular ×9
meteor ×7
typescript ×2
angularfire2 ×1
firebase ×1
fonts ×1
javascript ×1
node.js ×1
phantomjs ×1
roles ×1
seo ×1