我有一个 angular 项目,它有多个路由,/category/fruit/apple所以完整的 url 是http://myserver/category/fruit/apple通过路由器链接的,一切都很好,但是如果我直接在输入 URL 时打开这个链接,那么404我的后端是带有 express 的 nodejs。404 是有意义的,因为没有像这样配置的路由。
我的问题,在这种情况下我应该如何处理?
我以为我有,重定向到根http://myserver?path=category-fruit-apple并从根组件进行动态路由。这是正确的方法吗?
请建议最好的方法。
这是我的父组件 html
<app-card>
<div class="body">This is body</div>
<div class="title">This is title</div>
</app-card>
Run Code Online (Sandbox Code Playgroud)
这是我的 CardComponent
<div class="card">
<ng-content select=".title"></ng-content>
<ng-content select=".body"></ng-content>
</div>
Run Code Online (Sandbox Code Playgroud)
所以我想访问这个元素(<div class="body">This is body</div>CardComponent 中的这个元素 ( ),如果它是一个组件,我可以通过 ContentChild 访问它,但是如何访问它?
我尝试使用模板变量(在 ContentChild 中传递变量名称)并尝试从 ngAfterContentInit 获取未定义的形式访问它
我正在使用Chrome扩展程序,我想检测用户何时输入URL。我知道:
chrome.tabs.onUpdated.addListener(eventLisenerObj.onUpdated);
Run Code Online (Sandbox Code Playgroud)
但是,只要URL更改(例如,页面自动重新加载或用户单击链接等),它就会被调用。
我希望能够仅通过用户输入URL来确定URL是否已更改。
javascript jquery google-chrome-extension angularjs firefox-addon-webextensions
我正在尝试加载其他网站,我将在其中拥有网站列表。如果我单击网站链接,则必须在我的角度应用程序中打开该网站。是否有可用的角度选项或我可以用来加载网站的任何选项?
我已经尝试使用HTML标记元素iframe,embed,object和jquery加载函数来加载网站。一些网站正在打开,而某些网站限制在其他应用程序上打开
<html>
<body>
<iframe src="https://stackoverflow.com" height="100%" width="100%"></iframe>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在角
<div >
<iframe id="companyFrame" [src]="sourceURL | safe" class="frame">
</iframe>
</div>
@Pipe({ name: "safe" })
export class SafePipe implements PipeTransform {
constructor(private sanitizer: DomSanitizer) {}
transform(url) {
return this.sanitizer.bypassSecurityTrustResourceUrl(url);
}
}
Run Code Online (Sandbox Code Playgroud)
例如,我希望加载StackOverflow主页站点,但是出现诸如Refused之类的错误,因为它在框架中显示“ https://stackoverflow.com/ ”,因为它将“ X-Frame-Options”设置为“ sameorigin”。 如果网站所有者不希望将网页加载到iframe中,这是浏览器的默认选项。所以我想要替代选项而不是iframe
angular ×3
angularjs ×1
firefox-addon-webextensions ×1
html ×1
iframe ×1
javascript ×1
jquery ×1