Javascript 选择“单击不调用”

Javascript 选择“单击不调用”,javascript,angularjs,google-chrome,Javascript,Angularjs,Google Chrome,我不知道为什么它不在Chrome上运行,而在FireFox上运行 <div ng-app="myApp" ng-controller="MyCtrl"> <sampdir> {{msgClick}} <select ng-change="sortContent(item.value)" ng-model="item.value"> <option ng-selected="item.va

我不知道为什么它不在Chrome上运行,而在FireFox上运行

<div ng-app="myApp" ng-controller="MyCtrl">
    <sampdir>
        {{msgClick}}
        <select ng-change="sortContent(item.value)" ng-model="item.value">
           <option  ng-selected="item.value" class="sort_option" value="{{item.value}}" ng-repeat="item in selectModel" >
                        {{item.htmlText}}
                    </option>
                </select>        
    </sampdir>
</div>
选择型号

selectModel: [
                        {
                            value: "asc", htmlText : "A-Z", selected: ""
                        },
                        {
                            value: "desc", htmlText : "Z-A", selected: ""
                        },
                        {
                            value: "startDate", htmlText : "Date", selected: ""
                        }
                    ]
html 问题是该函数没有在googleChrome上调用

您可以在这里尝试: 适用于FFox,不适用于Chrome_
答案很简单<代码>Ng单击在
中不起作用。它在
中工作。两天前我也有类似的问题

我已经更新了。

使用ng app=“myApp”它会起作用此解决方案适用于您给定的小提琴

您的示例出现错误:

见本例:


{{d}


编辑:

请参见此示例:

现在,在您新编辑的小提琴中,您必须应用ng更改以选择不选择选项,并且当您使用ng更改时,它也需要mg模型


{{msgClick}}
{{item.htmlText}

这可能只是一个输入错误,但您的控制器列表中有一个不同的名称,在您的
ng repeat
中,您可以发布完整的代码或JS小提琴吗。有些部分不清楚。是的,你是对的,我复制了错误的部分:P,但这不是问题。是的,但是,“项目”是未定义的。你不能像那样发送项目。在选择中使用ng模型。更新答案中的链接。是的,你的答案就是我问题的解决方案,非常感谢:)没问题@基瓦尔:是的,ng变化也很好,我在问题陈述中使用了什么,但ng变化很昂贵。。还使用了OP(单击:)
return {
    restrict: 'E',
    replace: true,
    scope: {
    },
    link: function (scope, element, attributes) {
    scope.sortContent =  function(item_){
            console.info("???????????????????????????????????????????????????????????????????????????????")
        }
}
<div ng-app ="myApp" ng-controller="MyCtrl">
        {{d}}
</div>

<div ng-app="myApp" ng-controller="MyCtrl">
    <sampdir>
        {{msgClick}}
        <select ng-change="sortContent(item.value)" ng-model="item.value">
           <option  ng-selected="item.value" class="sort_option" value="{{item.value}}" ng-repeat="item in selectModel" >
                        {{item.htmlText}}
                    </option>
                </select>        
    </sampdir>
</div>