【问题标题】:What is wrong with angular component "bindings" parameter?角度组件“绑定”参数有什么问题?
【发布时间】:2016-12-04 13:08:02
【问题描述】:

我有一个角度组件,我想将其包含在我的页面中。 如果我在此组件中注释/删除 bindings 参数,一切正常...为什么?

(function () {

    angular.module('app').component('detailsComponent1', {
        templateUrl: '/RealSuiteApps/RealForm/-1/Details/Component1',
        restrict: 'E',
        bindings: {
            value: "Component1"
        },
        controllerAs: 'cm',
        controller: function () {
            this.message = 'Hello from component1';
        }
    });

})();

如果我想使用 binding 参数,我得到一个错误:

链接到:https://docs.angularjs.org/error/$compile/iscp?p0=detailsComponent1&p1=value&p2=Component1&p3=controller%20bindings%20definition

什么意思??

谢谢。

【问题讨论】:

  • 所以?模板来自MVC调用,与问题无关。我说,如果我删除绑定,一切都会正常...
  • 同时删除restrict: 'E',。错误是因为 value: "Component1" 使它像 value: @Component1value: =Component1

标签: angularjs angular-components


【解决方案1】:

好吧,错误是由于Invalid Isolate scope

在声明隔离作用域时,作用域定义对象必须采用特定格式,以模式字符(@&=开头,后面是可选的?,并以可选的本地名称结尾.

请在此处找到参考链接:https://docs.angularjs.org/error/$compile/iscp

另外,你在组件中有一些废弃的指令属性。

restrict(仅限于组件的元素)

请在此处查找组件文档:https://docs.angularjs.org/guide/component

希望对你有帮助!

干杯

【讨论】:

    猜你喜欢
    • 2019-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多