标签: angularjs

这个奇怪的 JavaScript 代码是如何工作的?神秘的结肠

我正在关注官方的 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)

angularjs typescript

7
推荐指数
1
解决办法
1795
查看次数

Angular Translate 有时无法通过一次性绑定进行翻译

我正在使用 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 或指令内部的元素,例如当它们位于子作用域内时,不会发生这种情况。

javascript angularjs angular-translate one-time-binding

7
推荐指数
1
解决办法
3022
查看次数

如何禁用对 Ag-grid 中特定列的排序?

我在我的一个 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)

但是如何在特定条件下动态进行,有关更多说明,请查看下图 在此处输入图片说明

在此,我按国家/地区对网格进行分组并扩大爱尔兰国家/地区,但现在我不禁用对任何参数的排序,并在删除分组属性时再次启用它。

有没有办法实现这一点,请告诉我,如果已经存在任何重复的问题,请在评论部分添加。

谢谢

angularjs ag-grid

7
推荐指数
2
解决办法
1万
查看次数

Angular CLI 是否与 Angular JS 兼容

我们正在将 Angular JS 应用程序升级到新的 Angular (Angular 4) 框架。我们设计的策略是,我们首先将 Angular JS 的内容从 javascript 转换为 typscript,然后逐个组件转换为新的 Angular 框架。但是,有没有办法让 Angular CLI 与 Angular JS 一起工作?

angularjs angular-cli angular

7
推荐指数
0
解决办法
3410
查看次数

即使在将域列入白名单后,firebase 身份验证域也未获得授权

我在启用Google 登录的Angular4 项目中使用Firebase Auth (firebase 4.1.3) 。在本地主机上工作时,一切都按预期工作。但是,在部署托管在 Google App Engine 上的应用程序时,身份验证弹出窗口失败并显示“auth/unauthorized-domain”错误。

如何在 Firebase 中将我的自定义域列入白名单?

已经完成的检查:

  1. 我的 Firebase 项目已启用计费并处于活动状态
  2. 带有弹出窗口的 Google 登录可在本地主机上运行
  3. Google 应用引擎域已在 Firebase 控制台的 Authenticacion 模块中登录方法下的“授权域”中列入白名单。
  4. 在我的 angular 应用程序中仔细检查了 javascript firebase 配置(我复制粘贴了 firebase 控制台给出的代码段)。
  5. 在 Google Cloud Console 中,默认的 Web API 密钥没有访问限制,并且 OAuth 客户端 ID 已经在“授权的 JavaScript 源”列表和“授权的重定向 URI”(https://console)列表中包含我的 App Engine 域.developers.google.com/apis/credentials?project=MYPROJECT)。

其他一些类似的 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

7
推荐指数
1
解决办法
3378
查看次数

throw new ERR_INVALID_ARG_TYPE('chunk',['string','Buffer'],chunk);TypeError[ERR_INVALID_ARG_TYPE]:“chunk”参数必须是字符串或缓冲区类型

我正在尝试.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)

json node.js angularjs

7
推荐指数
2
解决办法
3万
查看次数

角度键值管道:参数类型不可分配给参数类型

我想迭代一个地图并在我的 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) => …

html angularjs typescript ngfor angular

7
推荐指数
1
解决办法
2701
查看次数

Angularjs:本地存储内容可编辑不保存

当我尝试将其扩展为包含 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)

html javascript angularjs

7
推荐指数
1
解决办法
249
查看次数

AngularJS ng-repeat 通过复杂和动态的 JSON 数组

我正在尝试使用该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)

javascript arrays json angularjs

7
推荐指数
1
解决办法
122
查看次数

zsh:找不到命令:nx

我正在尝试使用 Angular 创建一个库,nx g @nrwl/angular:lib shared但它一直给我错误zsh: command not found: nx。我所做的只是创建一个角度项目。我尝试使用这个:npm install -g nx所以也许它安装了nx并且可以工作,但我仍然遇到同样的错误。

我怎样才能解决这个问题?我正在使用 Mac。如果有任何问题或需要信息,请随时在下面发表评论。

angularjs angular

7
推荐指数
4
解决办法
5215
查看次数