我想访问我的视图中的localhost:3000/admin .. index.html和admin.html是我的两个不同的基本文件,一个用于用户,另一个用于管理仪表板
在我的app.routes.js我有这个
angular.module('appRoutes', ['ngRoute'])
.config(function($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'app/views/pages/home.html',
controller: 'MainController',
controllerAs: 'main'
})
.when('/admin', {
templateUrl: 'app/views/admin.html',
})
.when('/logout', {
templateUrl: 'app/views/pages/home.html'
})
.when('/login', {
templateUrl: 'app/views/pages/login.html'
})
.when('/signup', {
templateUrl: 'app/views/pages/signup.html'
})
.when('/admin/login' ,{
templateUrl: 'app/views/pages/adminlogin.html'
})
$locationProvider.html5Mode(true);
})
Run Code Online (Sandbox Code Playgroud)
在server.js我有这个
app.get('*', function(req, res){
res.sendFile(__dirname + '/public/app/views/index.html');
});
Run Code Online (Sandbox Code Playgroud)
有两个html索引文件:index.html,admin.html我想打开admin.html时url是:localhost:3000/admin
和index.html当url是:localhost:3000时
在views/pages中我有index.html和admin.html使用ng-view所需的所有html页面
我正在尝试使用 I18n Angular 工具运行带有 dotnet 核心的 Angular 项目模板。(https://docs.microsoft.com/en-us/aspnet/core/spa/angular?tabs=visual-studio)
这是我在创业课上的内容
app.Map("/fr", fr =>
{
fr.UseSpa(spa =>
{
// To learn more about options for serving an Angular SPA from ASP.NET Core,
// see https://go.microsoft.com/fwlink/?linkid=864501
spa.Options.SourcePath = "ClientApp";
spa.UseSpaPrerendering(options =>
{
options.BootModulePath = $"{spa.Options.SourcePath}/dist-server/fr/main.bundle.js";
options.BootModuleBuilder = env.IsDevelopment()
? new AngularCliBuilder(npmScript: "build:ssr2:fr")
: null;
options.ExcludeUrls = new[] { "/sockjs-node" };
});
if (env.IsDevelopment())
{
spa.UseAngularCliServer(npmScript: "serve:fr");
}
});
});
app.Map("/en", en =>
{
en.UseSpa(spa =>
{
// To learn more about …Run Code Online (Sandbox Code Playgroud) internationalization angular-ui-router server-side-rendering angular-universal
我的理解是,在调用构造函数之一之前,不会激活注入的类(例如我的 MVC 项目中的控制器)。但是,是否可以立即强制激活 Singleton,这样我就不必等待调用控制器?我想我可以这样做:
services.AddSingleton(new MySingleton());
Run Code Online (Sandbox Code Playgroud)
但是如果 MySingleton 在其构造函数中使用 DI 呢?有没有办法调用构造函数?我应该更改构造函数以将 IServiceProvider 作为参数并手动提取依赖项吗?:
_myDependency = serviceProvider.GetService<MyDependency>();
Run Code Online (Sandbox Code Playgroud) 我是 angular2 的新手。我正在使用 ckeditor 创建一个反应式表单。一切都很好,但我的 ckeditor 数据没有发布。它是空的。我正在阅读指南并创建它,但我无法获得完美的结果。
im user form[formGroup] createPage 并在此表单中使用 ckditor。但我无法获得ckeditor的数据。我如何使用表单从 ckeditor 获取数据。在表单提交按钮中单击。
这是我的 ckeditor.ts 文件
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'CKEDITOR',
template: `
<textarea name="targetId" id="targetId" rows="rows" cols="cols">
{{content}}
</textarea>`
})
export class AdminCkeditorComponent implements OnInit {
content: any = "test content";
@Input() targetId;;
@Input() rows = 10;
@Input() cols;
constructor() { }
ngOnInit(){
window['CKEDITOR']['replace']( 'targetId' );
}
}
Run Code Online (Sandbox Code Playgroud)
这是 page.ts 文件
import { FormGroup, FormControl } from '@angular/forms';
import { Component, …Run Code Online (Sandbox Code Playgroud) 我正在尝试将使用EntityFrameworkCore(1.0.1)的.NET Core 1.1 MVC应用程序从SQLite("Microsoft.EntityFrameworkCore.Sqlite": "1.0.1")迁移到MySQL("MySql.Data.EntityFrameworkCore": "7.0.6-IR31")。
我的上下文正在扩展IdentityDbContext,并且在运行时Database.EnsureCreated(),使用Sqlite会自动配置AspNet表(RoleClaims,Roles,Users等)。
使用MySQL连接器,当我尝试运行Update-Database或时Database.EnsureCreated(),出现错误:
The entity type 'IdentityUser' is part of a hierarchy, but does not have a discriminator value configured.
我是否应该真正手动配置,如果可以,如何配置?
内容:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
//DbSets here..
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<IdentityUser>()
.HasDiscriminator<int>("Type")
.HasValue<ApplicationUser>(1);
}
}
Run Code Online (Sandbox Code Playgroud)
应用用户:
public class ApplicationUser : IdentityUser
{
public string Firstname { get; set; } …Run Code Online (Sandbox Code Playgroud)