Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angularjs$编译输入html或元素_Javascript_Angularjs - Fatal编程技术网

Javascript Angularjs$编译输入html或元素

Javascript Angularjs$编译输入html或元素,javascript,angularjs,Javascript,Angularjs,我正在阅读《使用AngularJS掌握Web应用程序开发》一书,并在第220页遇到了以下代码: var element = $compile('<button size="large"></button>')($rootScope) 但是,根据位于:,的文档,$compile函数需要angular.element包装的html输入 纯html和angular元素都是$compile函数的有效输入,还是其中一个文档不正确?如果有疑问-。 这永远是最好的选择 if (!

我正在阅读《使用AngularJS掌握Web应用程序开发》一书,并在第220页遇到了以下代码:

var element = $compile('<button size="large"></button>')($rootScope)
但是,根据位于:,的文档,$compile函数需要angular.element包装的html输入

纯html和angular元素都是$compile函数的有效输入,还是其中一个文档不正确?

如果有疑问-。 这永远是最好的选择

  if (!($compileNodes instanceof jqLite)) {
    // jquery always rewraps, whereas we need to preserve the original selector so that we can
    // modify it.
    $compileNodes = jqLite($compileNodes);
  }
因此,如果它只传递了一个jqLite元素,那么它会将它包装在一个jqLite元素中

这允许传递内容、jqLite元素或普通DOM元素

如果你在源代码中找不到你想要的东西。 您可以在第88行中看到:

 element = $compile('<div></div>')($rootScope);
如果你在规范中找不到。 嗯?那不是医生!这就是源头,你骗了我

根据我的经验,Angular在源代码中的记录要比在线文档中的记录好得多。文档更为最新,所有类型和用法都有。这里要简单得多:

@param{string | domeElement}元素或HTML字符串编译为模板函数。 虽然在这种情况下也做得不错,但导航时间更长

仍然没有-你可以退房。 这是TypeScript的一系列类型定义。它很有用,因为它可以很好地告诉您-类型:

 interface ICompileService {
        (element: string, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction;
        (element: Element, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction;
        (element: JQuery, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction;
    }
正如你所看到的,这是我们在别处找到的三种选择。字符串、元素或JQuery lite通常是一个实例

当有疑问时-。 这永远是最好的选择

  if (!($compileNodes instanceof jqLite)) {
    // jquery always rewraps, whereas we need to preserve the original selector so that we can
    // modify it.
    $compileNodes = jqLite($compileNodes);
  }
因此,如果它只传递了一个jqLite元素,那么它会将它包装在一个jqLite元素中

这允许传递内容、jqLite元素或普通DOM元素

如果你在源代码中找不到你想要的东西。 您可以在第88行中看到:

 element = $compile('<div></div>')($rootScope);
如果你在规范中找不到。 嗯?那不是医生!这就是源头,你骗了我

根据我的经验,Angular在源代码中的记录要比在线文档中的记录好得多。文档更为最新,所有类型和用法都有。这里要简单得多:

@param{string | domeElement}元素或HTML字符串编译为模板函数。 虽然在这种情况下也做得不错,但导航时间更长

仍然没有-你可以退房。 这是TypeScript的一系列类型定义。它很有用,因为它可以很好地告诉您-类型:

 interface ICompileService {
        (element: string, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction;
        (element: Element, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction;
        (element: JQuery, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction;
    }

正如你所看到的,这是我们在别处找到的三种选择。字符串、元素或JQuery lite通常是一个实例

似乎任何一个都是允许的:。但也许我看错了,似乎两者都是允许的。但也许我看错了thing@AlexanderMarquardt很高兴我能help@AlexanderMarquardt很高兴我能帮忙