我试图在一个新的离子2项目(最新的ionic2版本)中使用cordova GooglePlus插件,但我总是遇到有关cordova的错误.该插件已正确安装并显示在插件文件夹中.
我试过的一种方法是:
import { GooglePlus } from "ionic-native";
Run Code Online (Sandbox Code Playgroud)
然后
GooglePlus.login().then(...)
Run Code Online (Sandbox Code Playgroud)
登录方法执行但总是抛出错误说 "cordova_not_available"
我想先ionic serve在我的Windows系统上测试应用程序,然后再将其部署到我的Android手机上.如何在localhost服务器中提供cordova?从搜索中我了解到cordova.js已生成并始终包含在设备的deploy包中.
我尝试的另一种方法是使用
window.plugins.googleplus.login(...)
Run Code Online (Sandbox Code Playgroud)
但是这种方法不会通过对Windows对象上的插件属性一无所知的打字稿编译器.
我怎样才能解决这个问题?
我正在通过我的Android手机部署调试版本ionic run android.
如何查看console.log邮件?
我正在试验Angular 2 RC4中的表格.一切正常但是当我启动应用程序时,浏览器控制台会给我这样的消息:
*It looks like you're using the old forms module. This will be opt-in in the next RC, and will eventually be removed in favor of the new forms module.
Run Code Online (Sandbox Code Playgroud)
我的组件的相关部分如下所示:
import {
FORM_DIRECTIVES,
REACTIVE_FORM_DIRECTIVES,
FormBuilder,
FormGroup
} from '@angular/forms';
import {Observable} from "rxjs/Rx";
@Component
({
selector: "hh-topbar",
moduleId: module.id,
templateUrl: "topBar.component.html",
directives: [HHPagerComponent, FORM_DIRECTIVES, REACTIVE_FORM_DIRECTIVES]
})
export class HHTopBarComponent implements OnChanges, OnInit
{
...
private filterForm: FormGroup;
private title$: Observable<string>;
constructor(private formBuilder: FormBuilder)
{
}
public ngOnInit(): …Run Code Online (Sandbox Code Playgroud) 使用新驱动程序2.0构建索引的新方法是什么?没有关于此的任何文档.
显然这现在适用于新的IndexKeysDefinitionBuilder<>界面,但这是我到目前为止所有.
使用 1.10 版本的 .NET 驱动程序,我可以执行以下操作来获取 oplog 集合中的最大时间戳:
this.oplogCollection.AsQueryable<OplogEntry>().Max(o => o.ts);
Run Code Online (Sandbox Code Playgroud)
我怎样才能用新的驱动程序 2.0 做到这一点?该文档基本上不存在或没有帮助,所以我希望一些内部人士可以在这里有所启发。
我喜欢打字稿的一个原因是它的类型安全性,我一直使用它.
打字稿不支持多重继承,所以我如何通过扩展一个角2组件类OnInit,并OnChanges在同一时间?
我知道它可以在不声明继承的情况下工作但我喜欢我的代码没有波浪线.
如何说服Angular 4路由器在我的应用程序中禁用直接浏览器导航?
我已经查看了路由器钩子CanActivate并CanDeactivate实现了它们,但CanDeactivate在使用直接浏览器导航时根本不会触发.
我可以CanActivate用来阻止网址,但只有在应用程序重新启动后,这需要时间和浏览器窗口中的不需要的更改.
我希望能够在应用重新启动之前捕获直接浏览器导航.
如果这有帮助:我想完全禁止直接浏览器导航,所以我不需要允许某些网址并禁用其他网址的解决方案.
这是我的路由器定义:
const routes: Routes = [
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' },
{ path: 'dashboard', component: DashboardComponent, canActivate: [RouteGuardService] },
{ path: 'users', component: UsersMainComponent, canActivate: [RouteGuardService] },
{ path: 'vendors', component: VendorMainComponent, canActivate: [RouteGuardService] },
{ path: 'invoices', component: InvoicesMainComponent, canActivate: [RouteGuardService] },
{ path: 'offers' , component: EsdMainComponent, canActivate: [RouteGuardService] },
{ path: 'settings' , component: SettingsMainComponent, canActivate: [RouteGuardService] },
// Callback …Run Code Online (Sandbox Code Playgroud) 我正在使用WebStorm 2016.1.3进行带有打字稿的Angular 2项目.当我在WebStorm中启用ts编译器并修改ts文件(然后应该编译)时,我收到以下警告:Warning:File was not compiled because there is no a reference from tsconfig.json并且文件未编译.
我的项目文件/文件夹结构接近Angular 2推荐的样式指南:
我的所有ts文件都在一个script文件夹中.根应用程序位于该文件夹中,每个组件都有自己的子文件夹,其中包含一个ts和一个html文件.共享服务等位于Shared子文件夹中.
我tsconfig看起来像这样,并在项目根文件夹(文件夹的父文件script夹)中:
{
"compilerOptions": {
"outDir": "wwwroot/app",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"inlineSourceMap": true,
"inlineSources": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"wwwroot"
]
}
Run Code Online (Sandbox Code Playgroud)
除了ts直接在scriptWebStorm 中的所有其他文件中打开和修改的ts文件导致上面的警告并且不编译.在WebStorm的typescript控制台中,编译器说它正在编译修改后的文件(即更改检测似乎正在工作),但它不会发出转换文件.但是,当WebStorm启动时ts,所有子文件夹中的所有文件都已正确编译.此外,如果我手动或通过gulp使用tsc我没有问题,一切都应该编译,这告诉我,我tsconfig没事.我尝试在WebStorm的typescript编译器选项中指定我自己的范围.没有区别.该Track changes选项已启用.我试着和没有Resolve …
有人可以解释如何在ASP.NET Core rc2应用程序中存储和获取cookie吗?我只能找到有关旧方法HttpContext.Response.Cookies.Get和Add方法的过时信息,而Core中仍然没有这些信息.此外,HttpCookie该类似乎也不存在.
什么是新的cookie类,如何获取和添加一个?
(注意:我不是专门用于认证cookie,只是一般数据cookie)
我想手动引导Angular 4应用程序(使用CLI创建).在main.ts我这样做:
const injector = ReflectiveInjector.resolveAndCreate([
Http,
BrowserXhr,
{provide: RequestOptions, useClass: BaseRequestOptions},
{provide: ResponseOptions, useClass: BaseResponseOptions},
{provide: ConnectionBackend, useClass: XHRBackend},
{provide: XSRFStrategy, useFactory: () => new CookieXSRFStrategy()},
]);
const http = injector.get(Http);
http.get('assets/configs/configuration.json')
.map((res: Response) => {
return res.json();
}).subscribe((config: Configuration) => {
configuration = config;
console.log(JSON.stringify(configuration));
platformBrowserDynamic().bootstrapModule(AppModule);
});
Run Code Online (Sandbox Code Playgroud)
我似乎得到一个有效的Http实例,但当我使用它(http.get)时,我收到此错误:
Uncaught TypeError: Cannot read property 'getCookie' of null
at CookieXSRFStrategy.webpackJsonp.../../../http/@angular/http.es5.js.CookieXSRFStrategy.configureRequest (vendor.bundle.js:141626)
Run Code Online (Sandbox Code Playgroud)
我已经设置了一个空的WebAPI项目.NET Core rc2并将其连接起来Angular2 rc1.Angular将处理所有相关视图,WebAPI是后端.
当我默认启动应用程序时,它会localhost:4578/api/values从默认的API控制器中作为startpage启动.
但是,我希望它index.html默认显示位于wwwroot我的Angular2应用程序并托管我的应用程序.
在Startup.cs该Configure方法中看起来像这样:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
app.Run(ctx =>
{
ctx.Response.Redirect("/index.html");
return Task.FromResult(0);
});
}
Run Code Online (Sandbox Code Playgroud)
app.UseStaticFiles并且app.Runlambda需要到位以便手动重定向index.html才能工作,但它仍然是/api/values默认的起始页面.
我知道出于调试目的,我可以轻松地更改起始页面,但我想更改它,以便在我托管它时它始终用作index.html起始页面.
我怎么能改变这个?