我正在关注官方的 Angular 2 教程,然后我看到了这段代码:
const HEROES: Hero[] = ...
我不明白 HEROES 之后的冒号是如何出现的,我在 JavaScript 和 TypeScript 中找不到有关此冒号用法的任何文档。我认为冒号只用于对象“键:值”和三元运算符。
export class Hero {
id: number;
name: string;
}
const HEROES: Hero[] = [
{ id: 11, name: 'Mr. Nice' },
{ id: 12, name: 'Narco' },
{ id: 13, name: 'Bombasto' },
{ id: 14, name: 'Celeritas' },
{ id: 15, name: 'Magneta' },
{ id: 16, name: 'RubberMan' },
{ id: 17, name: 'Dynama' },
{ id: 18, name: 'Dr IQ' }, …Run Code Online (Sandbox Code Playgroud) 我正在使用 Angular 1.x,它是 Angular Translate 模块。最近,我将所有翻译绑定从双向切换为一次性。一切都工作正常,直到有一天,然而,我注意到有时如果我开始刷新页面,翻译实际上并没有被翻译。
例子:
{{ ::'MyTranslationKey' | translate }}
Run Code Online (Sandbox Code Playgroud)
90% 的情况下结果是正确的。然而,在另外 10% 中,渲染结果是:
MyTranslationKey
Run Code Online (Sandbox Code Playgroud)
这是什么原因?我该如何解决?
编辑:
对于 ng-if、ng-repeat 或指令内部的元素,例如当它们位于子作用域内时,不会发生这种情况。
我在我的一个 AngularJs 项目中使用https://www.ag-grid.com/。我的要求是在任何分组发生时禁用任何列的排序。
我知道我们可以sorting/filtering使用以下配置禁用单列:
colDef.suppressMenu = true
colDef.suppressSorting = true <--- this i can set up while giving column definition
Run Code Online (Sandbox Code Playgroud)
在此,我按国家/地区对网格进行分组并扩大爱尔兰国家/地区,但现在我不禁用对任何参数的排序,并在删除分组属性时再次启用它。
有没有办法实现这一点,请告诉我,如果已经存在任何重复的问题,请在评论部分添加。
谢谢
我们正在将 Angular JS 应用程序升级到新的 Angular (Angular 4) 框架。我们设计的策略是,我们首先将 Angular JS 的内容从 javascript 转换为 typscript,然后逐个组件转换为新的 Angular 框架。但是,有没有办法让 Angular CLI 与 Angular JS 一起工作?
我在启用Google 登录的Angular4 项目中使用Firebase Auth (firebase 4.1.3) 。在本地主机上工作时,一切都按预期工作。但是,在部署托管在 Google App Engine 上的应用程序时,身份验证弹出窗口失败并显示“auth/unauthorized-domain”错误。
如何在 Firebase 中将我的自定义域列入白名单?
已经完成的检查:
其他一些类似的 SO 问题是指检查之前的内容,甚至在将新域列入白名单以允许更改传播后最多等待 20 分钟。但这些建议都不适合我。
注意:完整的错误代码
{
code: "auth/unauthorized-domain"
message: "This domain (PROJECT.appspot.com) is not authorized to …Run Code Online (Sandbox Code Playgroud) google-app-engine angularjs firebase firebase-authentication
我正在尝试.json使用 node js 服务将文件的内容转换为 angularjs 方法。但我收到以下错误:
_http_outgoing.js:700 throw new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk); ^ TypeError [ERR_INVALID_ARG_TYPE]:“chunk”参数必须是字符串或缓冲区类型之一。在 ServerResponse.end (_http_outgoing.js:700:13) 接收到类型对象
这是相应的代码片段...
角度控制器:注释行都是我尝试过但失败的行。
var currentProcess = "process_1cA";
$scope.storestats = [];
var resAss = $resource('/procs/getstorestats');
var stats = resAss.get({
process: currentProcess,
date: date.getFullYear() + "" + m + "" + d
});
stats.$promise.then(function(response) {
if (response != undefined) {
// var r = JSON.parse(response);
//$scope.storestats.push(r);
//$scope.storestats.push(r);
//var r = JSON.parse(response);
$scope.storestats.push(response);
//angular.forEach(r, function(value, key) {
// $scope.storestats.push({key : value}); …Run Code Online (Sandbox Code Playgroud) 我想迭代一个地图并在我的 html 文件中显示键和值,为此我使用了 Angular 的 *ngfor 和键值管道。
但是,ngFor 迭代存在错误:
参数类型 Map<string, BarcodeInfoModel> 不可分配给参数类型 {[p: string]: (() => IterableIterator) | ((key: string, value: BarcodeInfoModel) => this) | ((key: string) => boolean) | 字符串 | ((key: string) => (BarcodeInfoModel | 未定义)) | (() => IterableIterator<[string, BarcodeInfoModel]>) | 数量 | (() => IterableIterator) | (() => 无效) | ((callbackfn: (value: BarcodeInfoModel, key: string, map: Map<string, BarcodeInfoModel>) => void, thisArg?: any) => void)} | Map<string, (() => IterableIterator) | ((key: string, value: BarcodeInfoModel) => …
当我尝试将其扩展为包含 contentEditable 时,本地存储停止工作。当我尝试将其扩展为包含 contentEditable 时,本地存储停止工作。以下是 CodePen 的链接:https ://codepen.io/zanderbush/pen/WNwWbWe 。任何帮助表示赞赏。
单独,这是有效的。
var app = angular.module('TodoApp', ["LocalStorageModule"]);
app.controller('TodoController', function($scope, localStorageService) {
if (!localStorageService.get("taskListActive")) {
$scope.tasksActive = [
{
text: "Do me next",
priority: 1,
complete: false
},
{
text: "I'm not important",
priority: 0,
complete: false
}
];
} else {
$scope.tasksActive = localStorageService.get("taskListActive");
}
if (!localStorageService.get("taskListComplete")) {
$scope.tasksComplete = [
{
text: "I'm already done",
priority: 0,
complete: true
}
];
} else {
$scope.tasksComplete = localStorageService.get("taskListComplete");
}
$scope.totalTasks = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用该ng-repeat选项从 JSON 数组向用户显示内容。这JSON Array是动态创建的,所以我有点困惑如何向用户显示相同的内容。
的语法JSON ARRAY如下,内容COMPLEX key可以动态增加或减少:
jsonList = [
{
name : "AB",
local : "CD",
complex : [
name : "EF",
local : "GH",
complex : [
name : "IJ",
local : "LL".
complex : ........
]
]
},
{
name : "PQ",
local : "RS",
complex : [
name : "TU",
local : "VW",
complex : [
name : "XY",
local : "Z1".
complex : ........
]
]
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Angular 创建一个库,nx g @nrwl/angular:lib shared但它一直给我错误zsh: command not found: nx。我所做的只是创建一个角度项目。我尝试使用这个:npm install -g nx所以也许它安装了nx并且可以工作,但我仍然遇到同样的错误。
我怎样才能解决这个问题?我正在使用 Mac。如果有任何问题或需要信息,请随时在下面发表评论。
angularjs ×10
angular ×3
javascript ×3
html ×2
json ×2
typescript ×2
ag-grid ×1
angular-cli ×1
arrays ×1
firebase ×1
ngfor ×1
node.js ×1