我正在关注NativeScript教程,但是当我尝试使用res://加载图像时,我无法使用iOS.
<Image src="res://logo" stretch ="none" />
Run Code Online (Sandbox Code Playgroud)
该文件位于App_Resources/iOS/logo.png中
更新:
现在有效:
1.-从设备/模拟器中卸载应用程序
2.-然后做一个新的tns build ios以获得新的构建
遵循NativeScript Groceries Typescript Angular教程,我在第3章遇到了以下错误.
EXCEPTION: Error in ./AppComponent class AppComponent_Host - inline template:0:0
ORIGINAL EXCEPTION: No provider for Http!
ORIGINAL STACKTRACE:
Error: DI Exception
at NoProviderError.BaseException [as constructor] (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/src/facade/exceptions.js:27:23)
at NoProviderError.AbstractProviderError [as constructor] (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/src/di/reflective_exceptions.js:43:16)
at new NoProviderError (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/src/di/reflective_exceptions.js:80:16)
at ReflectiveInjector_._throwOrNull (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/src/di/reflective_injector.js:786:19)
at ReflectiveInjector_._getByKeyDefault (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/src/di/reflective_injector.js:814:25)
at ReflectiveInjector_._getByKey (/data/data/org.nativescript.groce
Run Code Online (Sandbox Code Playgroud)
我在教程中来回走动,看看我是否错过了什么,但似乎我努力地遵循每一个步骤.
我该如何解决这个问题.
对于该项目,我们当前正在使用带有angular2的本机脚本启动,单元测试对我们来说至关重要。因此,我首先尝试为给定的Groceries示例实现一些简单的操作,以使其更实用。非常简单的测试,例如测试电子邮件地址的验证是否正常,并且执行起来并不繁琐。一旦我开始进行更复杂的测试,就只有在涉及Testbed时才出现错误。
这是我在Testbed上执行的最简单的启动实现:
import "reflect-metadata";
import 'nativescript-angular/zone.js/dist/zone-nativescript';
import {TestBed} from '@angular/core/testing';
import { UserService } from "../../../shared/user/user.service";
declare var describe: any;
declare var expect: any;
declare var it: any;
declare var beforeEach: any;
describe('UserService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [UserService]
});
});
it("just testing", () => {
console.log('hier');
expect(false).toBe(false);
});
});
Run Code Online (Sandbox Code Playgroud)
这是我运行该错误时会收到的那种错误:
sampleGroceries[66839]: CONSOLE LOG file:///app/tests/shared/user/user.service.spec.js:13:20: hier
NativeScript / 10.0 (10.0; iPhone) A suite contains spec with an expectation FAILED
TypeError: undefined is not an object (evaluating 'ProxyZoneSpec.assertPresent') …Run Code Online (Sandbox Code Playgroud) 我正在尝试处理NativeScript应用程序中的硬件后退按钮.我正在使用带有Angular的NativeScript版本2.3.0.
这是我在main.ts档案中的内容
// this import should be first in order to load some required settings (like globals and reflect-metadata)
import { platformNativeScriptDynamic, NativeScriptModule } from "nativescript-angular/platform";
import { NgModule,Component,enableProdMode } from "@angular/core";
import { AppComponent } from "./app.component";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { routes, navigatableComponents } from "./app.routing";
import { secondComponent } from "./second.component";
import {AndroidApplication} from "application";
@Component({
selector: 'page-navigation-test',
template: `<page-router-outlet></page-router-outlet>`
})
export class PageNavigationApp {
}
@NgModule({
declarations: [AppComponent,PageNavigationApp,secondComponent
// ...navigatableComponents
], …Run Code Online (Sandbox Code Playgroud) 我想打开/共享/发送文档到我的NativeScript应用程序中
例如(非NativeScript):https ://coderwall.com/p/83djxa/registering-your-app-to-be-able-to-open-images-from-other-apps
这里有一个android示例: 我可以共享到我的NativeScript应用程序吗?
iOS NativeScript有可能吗?(最终将同时需要android和iOS)
我正在尝试为Android创建一个Angular 2组件,用于显示特定路径的内容.为此,我创建了以下app-routing.module:
@NgModule({
imports: [
NativeScriptRouterModule.forRoot([
{ path: '', component: HomeComponent },
{ path: 'folder-content/:path', component: FolderContentComponent },
])
],
exports: [NativeScriptRouterModule]
})
Run Code Online (Sandbox Code Playgroud)
为了完整性,这里是folder-content.xml的xml
<StackLayout>
<GridLayout row="auto, *" row="2">
<ListView [items]="getContent(currentPath)">
<template let-item="item">
<GridLayout columns="auto, *" [nsRouterLink]="['/folder-content', item.path]">
<GridLayout columns="auto" rows="auto" cssClass="favorite-wrap">
<Image id="imgFav" [src]="item.isFile() ? 'res://ic_add_to_fav_1': 'res://folder'" stretch = "none" cssClass="icon-image"></Image>
</GridLayout>
<StackLayout col="1">
<Label [text]="item.name" cssClass="info-bigger"></Label>
<Label [text]="item.path" cssClass="info-orange"></Label>
</StackLayout>
</GridLayout>
</template>
</ListView>
</GridLayout>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
每次点击列表项时,我都想导航到同一页面,但是使用不同的参数(这可以按预期工作).
问题是当我尝试向后导航(使用物理后退按钮)时,我被重定向到HomeComponent而不是FolderContentComponent.
我尝试使用以下代码段打印路由器事件以获取更多信息:
router.events.forEach((event) => {
console.log(event);
});
Run Code Online (Sandbox Code Playgroud)
当从默认路径导航到 …
使用ngTemplateOutlet和context时:
<ng-container *ngTemplateOutlet="template; context: Context"></ng-container>
Run Code Online (Sandbox Code Playgroud)
上下文数据:
this.Context = {
$implicit: this.userName,
'password': this.password,
'Login': this.Login,
'Register': this.Register
};
Run Code Online (Sandbox Code Playgroud)
不能绑定2路绑定,这是一个限制还是我做错了什么?
<ng-template let-username #loginpage>
<TextField class="input" hint="Email" keyboardType="email" [(ngModel)]="username"></TextField>
</ng-template>
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
ns-renderer:无法分配给引用或变量!
我使用此代码上传图像:https: //github.com/NativeScript/sample-ImageUpload
当我上传图像时,我收到了成功通知.我正在尝试从服务器读取响应并检查任务的完整事件:
task.on("complete", logEvent);
function logEvent(e) {
console.log(JSON.stringify(e));
}
Run Code Online (Sandbox Code Playgroud)
这是输出:
{"eventName":"complete","object":{"_observers":{"complete":[{}],"propertyChange":[{}]},"_session":{"_id":"image-upload"},"_id":"image-upload{1}","_description":"{ 'uploading': Test0.png }","_upload":3807297,"_totalUpload":3807297,"_status":"complete"},"response":{}}
Run Code Online (Sandbox Code Playgroud)
如你所见,响应为空.那么如何从服务器读取响应?
I have an issue with routing in NativeScript 3.4 that drives me nuts. The idea of this test project is that the root app component is using a <page-router-outlet> and then using nested angular routing using <router-outlet> it loads a login parent and child, through which I am navigating to a main page which has two child routes.
If I route from the login.child.ts to the main parent/child with this.router.navigate(['/main']); then everything works fine and I continue alternating between the …
在我更新到最新版本的nativescript-toast之后,它停止了在iOS中的工作(在Android中工作正常)。我的意思是,当应用程序按预期运行时,没有显示吐司。
在以前的版本中,一切都按预期进行。但是,当我更新到新版本后,它停止工作,并且还将pod SBToaster添加到了我的podfile中。
这是package.json
"nativescript-toast": "^2.0.0",
Run Code Online (Sandbox Code Playgroud)
过去我有版本1.4.6
在我的Podfile中,我有:
pod 'SBToaster', '~> 2.1.2'
pod 'Toast'
Run Code Online (Sandbox Code Playgroud)
在我的组件中,我有:
Toast.makeText(message).show();
Run Code Online (Sandbox Code Playgroud)