我对Node.js比较陌生,一直在环顾四周但找不到解决方案.我确实检查了需要的javascript文件,它似乎没有"readFileSync"的方法.也许我没有合适的require文件?我很难找到这个文件,到处谈论它,但大多数人都没有发布到哪里去获取它.
我安装了Node.js并拥有require.js文件.我目前的代码是这样的:
fs = require(['require'], function (foo) {
//foo is now loaded.
});
console.log("\n *STARTING* \n");
// Get content from file
var contents = fs.readFileSync("sliderImages", 'utf8');
Run Code Online (Sandbox Code Playgroud)
我有一点开始需要工作,但似乎加载了需要的JavaScript文件.我一直在关注指南,我不知道为什么会出现这个错误:
未捕获的TypeError:fs.readFileSync不是函数
我尝试了很多修复工具,似乎无法解决这个问题.
在我的Android应用程序中,我在一个集合中有一堆网格在3D空间中移动.当触摸任何一个移动的网格(对象)时,我希望网格发生一些事情.如何检测已点击/单击的对象?
我们为什么要费心使用import { DOCUMENT } from '@angular/common'?
即使没有它,我也可以访问文档模块
document.getElementById('TestID).focus()
Run Code Online (Sandbox Code Playgroud)
我在导入中看到的唯一区别是将其附加到this关键字。
this._document.getElementById('TestID').focus();
Run Code Online (Sandbox Code Playgroud)
从 Angular 的通用模块导入 DOCUMENT 有什么真正的好处吗?
我做了一些研究,但看不到任何关于此的信息。
我正在尝试实施 Angular Material Typography,但是我遇到了一些困难,我不确定可能是什么问题。
我按照 Angular在此处提供的说明进行操作,但是遇到了问题。问题是看起来应用程序中的所有内容都受到了影响,但是有些内容被看起来像默认排版的东西覆盖了,我不确定我做错了什么。
$typography-configuration: mat-typography-config(
$font-family: 'Roboto, "Helvetica Neue", sans-serif',
$display-4: mat-typography-level(112px, 112px, 300),
$display-3: mat-typography-level(100px, 56px, 400),
$display-2: mat-typography-level(100px, 48px, 400),
$display-1: mat-typography-level(100px, 34px, 400),
$headline: mat-typography-level(100px, 32px, 400),
$title: mat-typography-level(100px, 32px, 500),
$subheading-2: mat-typography-level(100px, 28px, 400),
$subheading-1: mat-typography-level(100px, 24px, 400),
$body-2: mat-typography-level(100px, 24px, 500),
$body-1: mat-typography-level(100px, 22px, 400),
$caption: mat-typography-level(100px, 22px, 400),
$button: mat-typography-level(100px, 14px, 500),
$input: mat-typography-level(100px, 1.125, 400)
);
@include angular-material-typography($typography-configuration);
Run Code Online (Sandbox Code Playgroud)
正如您在排版中看到的100px那样,我故意设置了第一个参数(字体大小),以便我可以查看应用程序上的所有内容是否都受到影响。
对于 Angular Material 按钮(在 …
typography sass angular-material angular angular-material-theming
我是 Android 开发的新手,我正在尝试在屏幕顶部创建一个图像并使其落到底部。我一直环顾四周,无法得到正确的答案或指示。我发现的许多示例已经过时,而且许多方法不再有效。
我的 drawable 文件夹中有一个图像,我想在 10 秒后创建它,让它像有重力一样落向地面。
我已经看到很多关于 ObjectAnimator、画布、速度、动画的内容。我不知道从哪里开始。
这个问题与其他问题类似; 但是有一个区别让它变得非常混乱,为什么它不起作用.
我的JavaScript调用了6个json文件,并且都正常工作.在Node.JS中,我设置了cors和header,如下所示:
var fs = require('fs');
var http = require("https");
var express = require('express');
var app = express();
var path = require('path');
var http = require("http");
var url = require("url");
var req = require('request')
var pem = require('pem');
var cors = require("cors");
app.use(express.static(path.join(__dirname, '../')));
app.listen(process.env.PORT || 8080);
app.options('*', cors());
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested- With, Content-Type, Accept");
next();
});
app.all('/posts', function(req, res){
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
});
app.get('/', function (req, res) { …Run Code Online (Sandbox Code Playgroud) mat-stepper使用动态模板时,角材出现问题。例如,我有一个具有3个步骤的步进器,每个步骤都有自己的形式。但是,第一步使用隐藏表单来确定它是否有效,因为此步骤可以动态添加更多表单,因此将所有表单绑定到该步骤是不可能的。
第一步时,您可以创建多个表单,并且一切都会按预期进行,而不会对添加的新表单进行任何随机验证。如果您转到步骤2或3,然后回到第一步,然后创建一个新表单,它将自动以所有突出显示为红色的字段开始,就会出现问题。
我尝试了多种尝试来压制,但是我没有成功。下面是一个基本示例,说明我的第一步如何包含与步骤控件绑定的hiddenForm,默认表单以及在该步骤中创建更多表单的按钮。
我试图解决此问题的研究使我相信,无论是否新添加,材料步进器都会使所有垫形场变为红色(如果无效)。
<mat-horizontal-stepper [linear]="true">
<mat-step [stepControl]="hiddenForm" label="step 1"
<form [formGroup]="myForm">
<mat-form-field>
<mat-label>
First Name
</mat-label>
<input [formControl]="firstName"matInput>
<mat-error *ngIf="!firstName.valid && firstName.touched">
First Name required
</mat-error>
</mat-form-field>
</form>
<button (click)="AddNewForm()">Add New Form</button>
</mat-step>
</mat-horizontal-stepper>
Run Code Online (Sandbox Code Playgroud)
尝试失败的尝试:(当前表单是新添加的表单)
this.currentForm.markAsUntouched();
this.currentForm.markAsPristine();
this.currentForm.setErrors(null);
this.currentForm.reset();
this.currentForm.get('firstName).setErrors(null);
this.currentForm.get('firstName).reset();
this.currentForm.get('firstName).markAsPristine();
this.currentForm.get('firstName).markAsUntouched();
<mat-step [completed]="true" ..> ( on all steps )
Run Code Online (Sandbox Code Playgroud) 我使用以下方法创建了许多动态组件:
this.factory = this.componentFactoryResolver.resolveComponentFactory(SliderComponent);
this.sliderComponentReference = viewContainerRef.createComponent(this.factory);
Run Code Online (Sandbox Code Playgroud)
当我需要销毁组件时,我调用destroy方法:
this.sliderComponentReference.destroy();
Run Code Online (Sandbox Code Playgroud)
我了解到它从视图及其实例中删除了动态组件,但是当我立即看到变量后仍然注意到以下信息时,便可以看到它:
changeDetectorRef: ViewRef_ {_view: {…}, _viewContainerRef: ViewContainerRef.. }
componentType:(...)
hostView: ViewRef_ {_view: {…}, _viewContainerRef: ViewContainerRef... }}
injector:(...)
Run Code Online (Sandbox Code Playgroud)
问题:
如果变量被销毁了,为什么变量仍然引用组件实例?
组件是否仍存储在内存中?如果是这样,是否可以检索?
我有一个用三个项目创建的 Angular 工作区。以及我刚刚创建了一个库,我希望在其中包含可重用的模块。
通常对于项目(应用程序和库),我运行以下命令来生成模块或组件:
ng g c component componentName --project=UserPortal
ng g c component componentName --project=myLibrary
但是现在我需要向其中的模块添加组件:
例如库: projects myLibrary src lib navigation-module Add Component here
对于应用项目模块: projects UserPortal src app userModule Add Component Here
我能够通过运行在工作区的库项目中创建一个模块:
ng generate module navigation-module --project=myLibrary
目前我必须通过命令行进入该目录才能创建一个组件。但我有一种感觉,我可以像所有其他命令一样从工作区执行此操作。这将是最有益的,而不必在目录之间进行命令行排列或来回切换。
快速概览:
module angular-module angular-components angular angular-library
我创建了一个 Angular 库。在我的库中,我希望通过在其中包含功能模块来使其变得干净:
例子:
Library
NavigationModule
NavigationSideBarComponent
NavigationTopComponent
Navigation Service
etc
GraphModule
BarGraphComponent
PieGraphComponent
Run Code Online (Sandbox Code Playgroud)
我的导航模块目前如下所示:
@NgModule({
declarations: [
NavigationSidebarComponent
],
imports: [
CommonModule,
MatSidenavModule
],
exports: [
NavigationSidebarComponent
]
})
export class NavigationModule { }
Run Code Online (Sandbox Code Playgroud)
我的图书馆模块目前如下所示:
@NgModule({
declarations: [LibraryComponent],
imports: [
NavigationModule
],
exports: [
LibraryComponent
//NavigationSidebarComponent <-- Did not work
]
})
export class LibraryModule { }
Run Code Online (Sandbox Code Playgroud)
我发现的大多数教程都使用一个仅包含组件的库,而没有其他内容,例如模块。我发现使用库中的模块的教程没有显示如何导出片段。
本质上,我想将此库导入到任何应用程序中,并能够NavigationSidebarComponent从库或服务中的模块调用或任何其他组件。
我将继续调查此事。
angular ×6
android ×2
javascript ×2
node.js ×2
ajax ×1
angular6 ×1
animation ×1
components ×1
cors ×1
destroy ×1
document ×1
dom ×1
dynamic ×1
export ×1
express ×1
gravity ×1
import ×1
java ×1
jquery ×1
module ×1
opengl-es ×1
readfile ×1
reference ×1
sass ×1
typescript ×1
typography ×1
validation ×1