【问题标题】:What does ngf prefix mean in angularjs and ng-file-upload?ngf 前缀在 angularjs 和 ng-file-upload 中是什么意思?
【发布时间】:2016-12-10 04:45:36
【问题描述】:

我在 AngularJS 的 ng-file-upload 中遇到了一个 ngf-select 指令。它的用法像

<button type="file" ngf-select="uploadFiles($file, $invalidFiles)"
        accept="image/*" ngf-max-height="1000" ngf-max-size="1MB">
   Select File
</button>

我设法找到很少关于它代表什么的信息。我只能猜测它类似于 select 事件的 if 条件。我很确定我错过了文档中的某些部分,我不想靠猜测来解决问题。

谁能解释一下 ngf 前缀的作用并可能给出文档链接?

【问题讨论】:

  • DuckDuckGo 搜索“ngf-select”的第三次点击:npmjs.com/package/ng-file-upload 它描述了指令并给出了一个解释上述内容的示例。
  • 每个 Angular 模块通常为其指令使用不同的“命名空间”以避免冲突。 ng-file-upload 使用 ngf-*.
  • @danial 所以,这个 ngf-* 前缀只是指 ng-file-upload 也可以是 fff-*,对吧?
  • @danial 非常感谢,这就是我的问题的答案!

标签: javascript angularjs angularjs-directive ng-file-upload


【解决方案1】:

关于这个有很多讨论,但大多数人说前缀 ng 代表“Angular;” Angular 附带的所有内置指令都使用该前缀。同样,建议您不要在自己的指令中使用 ng 前缀,以避免在未来版本的 Angular 中可能出现名称冲突。像这样“ngf”是文件上传的内置指令

有些人说 ng 听起来像 Angular

有些人可能会说 ng 代表“下一代”,因为 angular 的功能正在蓬勃发展......

请检查一下

https://docs.angularjs.org/api/ng

【讨论】:

  • 在谷歌搜索时,我看到了像 ngf-accept 和 ngf-pattern 这样的指令,但我不记得在官方 angularjs 文档中看到过它们。为什么不使用标准的 ng 后缀?
猜你喜欢
  • 1970-01-01
  • 2016-03-11
  • 1970-01-01
  • 2017-04-30
  • 2016-11-15
  • 1970-01-01
  • 2010-10-03
  • 1970-01-01
相关资源
最近更新 更多