我已经通过npm安装了angular2 cli,但是当我尝试使用'ng new my-app'命令创建一个新的typescript角度应用程序时,我不断收到此错误:
C:\Users\nicholas\AppData\Roaming\npm\node_modules\@angular\cli\models\config\config.js:15
constructor(_configPath, schema, configJson, fallbacks = []) {
^
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\Users\nicholas\AppData\Roaming\npm\node_modules\@angular\cli\models\config.js:2:18)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
Run Code Online (Sandbox Code Playgroud)
我的NPM版本是4.1.2我的节点版本是4.4.5,根据我的理解,这是安装和使用angular-cli的可接受版本.
如果有解决方法,请告诉我,我也尝试卸载,清理npm缓存并重新安装,但我一直遇到同样的问题.
任何和所有的帮助非常感谢,提前感谢!
所以我试图将 TinyMCE 用于应用程序中的编辑器。我已经正确安装了 npm 模块,将皮肤复制到我的资产文件夹中,并将脚本正确添加到我的 angular-cli.json 中。这是我对我所做的EditorComponent
:
import { Component, OnInit, AfterViewInit, EventEmitter, Input, Output } from '@angular/core';
import 'tinymce';
declare var tinymce: any;
@Component({
selector: 'app-editor',
templateUrl: './editor.component.html',
styleUrls: ['./editor.component.scss']
})
export class EditorComponent implements OnInit, AfterViewInit {
@Input() elementId: string;
@Output() onEditorKeyup = new EventEmitter<any>();
editor: any;
constructor() { }
ngOnInit() {
}
ngAfterViewInit() {
tinymce.init({
selector: '#' + this.elementId,
plugins: ['link', 'paste', 'table'],
skin_url: 'assets/skins/lightgray',
setup: editor => {
this.editor = editor;
editor.on('keyup', () => …
Run Code Online (Sandbox Code Playgroud) 所以我在Angular 6 webapp中设置了AngularFire,并且一直在尝试使用AngularFireStorage.我已正确地按照文档进行上传,我可以在Firebase中看到图像已上传到特定位置并使用我提供的特定文件路径.这是代码:
uploadFile(e) {
const file = e.target.files[0];
const filePath = `test${this.uid}`;
const task = this.storage.upload(filePath, file);
const dlUrl = task.downloadURL();
dlUrl.subscribe((res) => {
console.log(res);
});
}
Run Code Online (Sandbox Code Playgroud)
每当我调用console.log(res)
它时,它返回一个未定义的值.我没有收到AngularFireStorage的实际下载URL,只是总是返回undefined
.我可以验证是否将正确的映像上传到存储桶中,即使它具有相同的文件名,也会覆盖旧的映像.为了尽可能清楚这里是<input>
文件:
<input type="file" accept=".jpg,.jpeg,.png;capture=camera" (change)="uploadFile($event)">
我不确定在图像成功上传时会出现什么问题,我在控制台中得到零错误,但总是返回一个未定义的字符串.任何和所有的帮助非常感谢,提前感谢!
编辑:对于仍然关注这篇文章的人,我最终只是使用firebase
方法和包,并跳过angularfire2
了存储功能.这是我用来代替angularfire2/storage
方法的方法.
我在服务中创建了一个上传方法,BehaviorSubject<number>
用于将百分比传递给我的组件:
percentSubject: BehaviorSubject<number> = new BehaviorSubject(0);
constructor() { }
pushUpload(file) {
return new Promise((resolve, reject) => {
const storageRef = firebase.storage().ref();
const uploadRef = storageRef.child(`uploads/${file.name}`);
this.uploadTask = uploadRef.put(file);
this.uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED,
(snapshot: firebase.storage.UploadTaskSnapshot) …
Run Code Online (Sandbox Code Playgroud) 我试图从存储中读取图像路径,我在这里继续获取SecurityException:
Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=31409, uid=10053 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
Run Code Online (Sandbox Code Playgroud)
我正在编译反对api 23并且在我的Manifest中明确说明了我的Manifest的直接子项.我也理解新的运行时权限声明,当您想要访问存储时,您必须在运行时请求权限.当我写这行开始检查权限时,我得到一个无法在IDE中解决的问题:
ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
Run Code Online (Sandbox Code Playgroud)
无法解析符号Manifest.permission.READ_EXTERNAL_STORAGE.我可以在我的代码中明确说明的唯一Manifest.permission是Manifest.permission.C2D_MESSAGE而没有得到无法解决的错误.还有其他我需要编译才能访问代码中的其他权限吗?
要清楚这是给我SecurityException的代码块:
public List<String> getCameraImagesFull(Context context) {
Cursor cursor = null;
String[] star = {"*"};
ArrayList<String> result = new ArrayList<>();
cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, star, null, null, MediaStore.MediaColumns.DATE_ADDED + " DESC");
if (cursor != null) {
if (cursor.moveToFirst()) {
do {
String path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
result.add(path);
} while (cursor.moveToNext());
}
cursor.close();
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
这是抛出异常的行:
cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, star, …
Run Code Online (Sandbox Code Playgroud) android mediastore android-permissions android-6.0-marshmallow
我有一个 ScrollView,它有一个 ViewTreeObserver.OnScrollChangedListener,这不是问题,但是一旦我设置 OnTouchListener 来确定 ScrollView 何时停止滚动,滚动视图上的甩动动作就不再发生。这是我的代码:
如果我这样做,它实际上并没有运行我为 onTouch 事件所拥有的方法,并且仍然会发生抛掷:
@Override
public boolean onTouch(View view, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
horizontalScrollClipping((ScrollView)view, view.getScrollY());
return false; //returning false instead of true
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
如果我这样做,onTouch 事件中的方法会触发,但不会发生滚动视图的抛出:
@Override
public boolean onTouch(View view, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
horizontalScrollClipping((ScrollView)view, view.getScrollY());
return true; //returning true instead false
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
最后,如果我这样做,ScrollView 上的滚动将完全禁用:
@Override
public boolean onTouch(View view, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
horizontalScrollClipping((ScrollView)view, view.getScrollY()); …
Run Code Online (Sandbox Code Playgroud) 嘿所以我有一个非常奇怪的问题,我在设置角度路由之前没有遇到过,当我试图延迟加载另一个模块时,我不断收到此错误 Error: Cannot find module "app/feed/feed.module"
从这里开始是我的设置
另外需要注意的是,我刚刚更新了所有的全局npm软件包后生成了一个新的角度项目,因此列出的内容在我运行之前已经更新到了 ng new app-name
这是我的app-routing.module
:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const rootRoutes: Routes = [
{ path: '', redirectTo: 'feed', pathMatch: 'full' },
{ path: 'feed', loadChildren: 'app/feed/feed.module#FeedModule' }
];
@NgModule({
imports: [RouterModule.forRoot(rootRoutes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
Run Code Online (Sandbox Code Playgroud)
然后app.module
我在上面导入这个模块:
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
AppRoutingModule
], …
Run Code Online (Sandbox Code Playgroud) angular ×4
android ×2
angular-cli ×1
angularfire2 ×1
firebase ×1
mediastore ×1
node.js ×1
tinymce ×1