在Angular 4(Material)应用程序中,我有一个用于搜索的文本字段.当我在字段中键入时,会出现第二个字段,显示输入的文本.滚动页面时,这个新字段会浮动.如何禁用浮动行为?
它似乎不是文本字段的默认行为.我试过了md-no-float,但那是我理解的占位符文字.有人建议设置为空value,所以我补充说,但问题仍然存在.
<md-input-container md-no-float style="width: 100%">
<input mdInput formControlName="search" value="" placeholder="Search Terms" />
</md-input-container>
Run Code Online (Sandbox Code Playgroud) 我将现有的.js和.css文件添加到使用angular-cli 1.0.6的Angular 4应用程序中.在最近的升级之前,我只是在index.html中引用它们 - 我知道这是'错误'但它适用于我当前的需求.
在最近的更新之后,我为我尝试过的所有内容获得了404.我设法通过将JavaScript文件添加到angular-cli.json然后将其导入组件来添加JavaScript文件.这是有效的,但同样不适用于.css文件.
我在index.html中尝试过它:<link rel="stylesheet" type="text/css" href="/scripts/test.css">
我已经在组件的模板中<link rel="stylesheet" type="text/css" href="../../../app/scripts/test.css">
尝试过:我已经尝试将它添加到组件中的样式:styleUrls: ['../edit.scss', '../../scripts/test.css'],
即使路径有效(我可以在编辑器中关注它们),我也会为所有这些设备获得404.
这样做的正确方法是什么?
("[routerLink]")在包含卡片的整个组件周围放置锚标记会更改样式(创建链接类以尝试禁用样式无济于事)。
动态创建(例如ngFor)卡(在这种情况下为md卡)作为可点击链接的正确方法是什么?
换句话说,每个卡都是可单击的,并链接到不同的视图。
我的 Angular 5 应用程序使用 构建得很好npm start,但是当我导航到 Chrome 中的特定组件时,我在控制台中收到了这个神秘的错误。我在搜索中找不到任何提及它的内容。
(我正在尝试将此组件从 Angular 4 升级到 Angular 5。)
core.js:1350 ERROR Error: Uncaught (in promise): Error: StaticInjectorError[Window]:
StaticInjectorError[Window]:
NullInjectorError: No provider for Window!
Error: StaticInjectorError[Window]:
StaticInjectorError[Window]:
NullInjectorError: No provider for Window!
at _NullInjector.get (core.js:923)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024)
at resolveNgModuleDep (core.js:10584)
at NgModuleRef_.get (core.js:11805)
at resolveNgModuleDep (core.js:10584)
at _NullInjector.get (core.js:923)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024) …Run Code Online (Sandbox Code Playgroud) 我使用一些 REST 服务来收集数据,然后更改组件代码中 Observable 的值。我正在尝试使用 *ngIf 根据结果显示/隐藏 div 标签。但是,它不起作用, *ngIf 没有根据 Observable 的更改进行更新。
我必须触发变更检测吗?在 Angular 7 中实现这一目标的最佳方法是什么?这是我尝试过的一个例子:
HTML:
<div *ngIf="isAnimal$">
<p>animal</p>
</div>
Run Code Online (Sandbox Code Playgroud)
成分:
public isAnimal$: Observable<boolean> = of(false);
...
ngOnInit() {
checkAnimal();
}
private checkAnimal() {
this._dataService.getData()
.subscribe((result) => {
if (result === 'animal') {
this.isAnimal$ = of(true);
}
});
}
Run Code Online (Sandbox Code Playgroud)
我还尝试创建一个简单的服务,但这也不起作用。像这样:Angular *ngIf 绑定到函数
我创建了一个新的 GitHub 应用程序,我正在尝试从 Node.js 进行身份验证。例如,我是 GitHub Apps 的新手,我不知道“installationId”应该是什么。那是应用ID吗?
我使用私钥成功获取了令牌,但是当我尝试使用 API 时,我收到来自 Node 和 curl 的错误。
import { createAppAuth } from '@octokit/auth-app';
import { request } from '@octokit/request';
const privateKey = fs.readFileSync(__dirname + 'file.pem');
const auth = createAppAuth({
id: 1,
privateKey,
installationId: 12345,
clientId: 'xxx.xxxxxx',
clientSecret: 'xxxxxx',
});
const appAuthentication = await auth({ type: 'app' });
console.log(`Git repo token: ` + appAuthentication.token);
const result = await request('GET /orgs/:org/repos', {
headers: {
authorization: 'token ' + appAuthentication.token,
},
org: 'orgname',
type: 'public', …Run Code Online (Sandbox Code Playgroud) angular ×5
angular7 ×1
css ×1
github-api ×1
github-app ×1
node.js ×1
observable ×1
octokit-js ×1
rxjs ×1