我正试图在http://moroshko.github.io/seekdeck的 GitHub页面上设置我的Angular应用程序.
Angular路线定义application.js如下:
<html ng-app="SeekDeck">
<head>
...
<script src="scripts/application.js"></script>
...
</head>
<body>
<div ng-view></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
application.js是/seekdeck/scripts按预期加载的.
我的应用程序路线如下所示:
// Part of application.js
$routeProvider
.when("/", {
templateUrl: "templates/dashboard/dashboard.html",
...
})
...
Run Code Online (Sandbox Code Playgroud)
当Angular尝试获取dashboard.html模板时,它会尝试从而/templates/dashboard不是加载模板,/seekdeck/templates/dashboard因此无法找到它.
任何想法为什么会发生这种情况,或者我该如何解决这个问题?
我有一个rails应用程序,使用angularjs进行客户端开发.我尝试加载位于`app/assets/javascripts/templates /'的模板:
myApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/', {
templateUrl: '/index.html',
controller: 'MainController'
}).
otherwise({
redirectTo: '/'
});
}]);
Run Code Online (Sandbox Code Playgroud)
但我总是收到一个错误:"错误:[$ compile:tpload]无法加载模板:/index.html".
我试图将"templates"文件夹移出javascripts - app/assets/templates,并通过在config/application.rb中添加以下行将其添加到我的资产管道加载中: config.assets.paths << Rails.root.join("app","assets","templates")
在我使用模板的完整路径之前,我一直收到相同的错误消息:templateUrl: '/assets/index.html',.
为什么第一种方法不够用?angular-rails-templates gem不应该在app/assets/javascripts/templates中查找模板?
我为什么要在javascript中使用资源的完整路径?
ruby-on-rails angularjs angular-routing ngroute angularjs-templates
如果可以将 path: ' ' 重定向到 path: ':id' ,我正在徘徊?有没有办法实现这一目标?
谢谢你。
{
path: 'folder',
children: [
{
path: '',
redirectTo: ':id',
pathMatch: 'full',
},
{
path: ':id',
canActivate: [AuthGuard],
component: DocumentsComponent,
},
]
}
Run Code Online (Sandbox Code Playgroud) 我正在使用通用cli ...
我的app.node.module.ts看起来像这样:
/**
* This file and `main.browser.ts` are identical, at the moment(!)
* By splitting these, you're able to create logic, imports, etc that are "Platform" specific.
* If you want your code to be completely Universal and don't need that
* You can also just have 1 file, that is imported into both
* client.ts and server.ts
*/
import {NgModule} from '@angular/core';
import {UniversalModule} from 'angular2-universal';
import {FormsModule} from '@angular/forms';
import {AppComponent} from './index';
import {AlertModule, CollapseModule, …Run Code Online (Sandbox Code Playgroud) 我想在我的登录/注册页面上隐藏我的布局,但是我不确定如何正确地进行布局。我不想在这些页面上使用覆盖层来覆盖布局,并且我不应该通过询问它是什么路线并在遇到某些路线时隐藏元素来完成此操作。
我的布局组件:
<div class="body-wrapper">
<div class="content">
<app-header></app-header>
<router-outlet></router-outlet>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
因此,我需要路由器出口仅显示登录组件,而不显示其他html。
我在页脚中有一个指向条款页面的链接,但我希望该链接指向条款网页的特定部分(条款中的第 3 段)。
这是代码 footer.component.html
<a routerLink="terms">Terms & conditions</a> |
<a routerLink="terms">Privacy policy</a> |
<a routerLink="terms">Cancellation policy</a>
Run Code Online (Sandbox Code Playgroud)
在terms.component.html我希望点击时打开页脚中的隐私政策链接的地方。
<ol start="3">
<li>INFORMATION SUBMITTED THROUGH OR TO OUR SERVICES</li>
</ol>
Run Code Online (Sandbox Code Playgroud)
我们需要用什么来让这些工作?任何帮助表示赞赏。谢谢。
如果我们使用<router-outlet>组件(任何组件)然后将a放到routerLink该组件中的另一个组件,链接是否始终呈现链接到<router-outlet>当前活动组件的组件?
换句话说,组件routerLink属性是否始终与<router-outlet>组件内部配对?
我有每个路由模块的这个多级模块,但只有第一个路由模块工作,第二个模块不工作.
每个模块都是延迟加载,默认路径是针对第一个模块.
app.module
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
CoreModule,
SharedModule,
FeaturesModule,
RouterModule.forRoot([
{ path: '', loadChildren: './features/features.module#FeaturesModule'}
]),
],
providers: [],
bootstrap: [AppComponent]
})
Run Code Online (Sandbox Code Playgroud)
features.module
@NgModule({
imports: [
CoreModule,
FeaturesRoutingModule,
MainModule,
RegisterModule
]
})
//routing
const routes: Routes = [
{ path: '', loadChildren: './main/main.module#MainModule' },
{ path: NAVIGATIONS.REGISTER, loadChildren: './register/register.module#RegisterModule' },
];
Run Code Online (Sandbox Code Playgroud)
main.module
@NgModule({
imports: [
CoreModule,
SharedModule,
MainRoutingModule,
MainFeaturesModule
],
/..../})
// routing
const routes: Routes = [
{
path: '', component: MainPageComponent,
children: [
{ path: …Run Code Online (Sandbox Code Playgroud) 我在Windows服务器的IIS上部署了使用angular 6开发的应用程序。现在,我面临的一个问题是,如果刷新页面,则在浏览应用程序时会显示404-找不到文件或目录。 我查看了与此问题相关的帖子,并尝试应用修复程序。但没有运气。我不想在网址中使用#。我只想使用像http://example.xyz.com/detail/12这样的网址
如果我正在使用#,则可以,但是我不想使用#。
我也尝试添加一个web.config,但是没有舔。任何人都可以在这里帮助如何解决此问题,以便在刷新时可以打开要重新加载的同一页面。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="./index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud) 我想导入我在应用程序中创建的模块,以将其加载到具有其自身路由的特定路由上
angular-routing ×10
angular ×8
angularjs ×2
javascript ×2
github-pages ×1
html ×1
lazy-loading ×1
module ×1
ngroute ×1
node.js ×1
routing ×1