Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.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
Html 简单的AngularJS脚本在Chrome中工作,但在IE11中失败_Html_Angularjs - Fatal编程技术网

Html 简单的AngularJS脚本在Chrome中工作,但在IE11中失败

Html 简单的AngularJS脚本在Chrome中工作,但在IE11中失败,html,angularjs,Html,Angularjs,我在书中有一个简单的AngularJS(v1.3.0-rc.1)页面(见下文),《为.NET开发人员学习AngularJS》(Packt Publishing)第13页,它在Chrome中工作,但在IE11中无法正确地提取。IE中的F12选项显示未拾取样式,。IE11中会出现什么问题 <!DOCTYPE html> <html ng-app> <head> <meta charset="utf-8" /> &

我在书中有一个简单的AngularJS(v1.3.0-rc.1)页面(见下文),《为.NET开发人员学习AngularJS》(Packt Publishing)第13页,它在Chrome中工作,但在IE11中无法正确地提取
。IE中的F12选项显示未拾取样式,
。IE11中会出现什么问题

<!DOCTYPE html>
<html ng-app>
    <head>
        <meta charset="utf-8" />
        <title>Chapter 1 Example - AngularJS</title>
        <script src="Scripts/angular.js"></script>
    </head>
    <body>
        <h1>Introduction</h1>
        <label>My name:</label>
        <input type="text" placeholder="Please enter name" ng-model="name" />
        <br />
        <label>My favorite color:</label>
        <select ng-model="color">
            <option>Please select</option>
            <option>red</option>
            <option>yellow</option>
            <option>magenta</option>
        </select>
        <h3 ng-show="name">Hello! My name is {{name}}.</h3>
        <h3 ng-show="color">My favorite color is <span title="{{color}}" style="background-color:{{color}};">&nbsp;&nbsp;</span></h3>
    </body>
</html>

第1章示例-AngularJS
介绍
我的名字:

我最喜欢的颜色: 请选择 红色 黄的 洋红 你好我的名字是{{name}。 我最喜欢的颜色是
这可能会失败,因为浏览器试图在AngularJS获得字符串并用设置的任何值替换
{{color}}
之前应用样式

Angular提供了一些特定于角度的属性来处理这种差异(
ng style
ng href
,等等)

尝试将该跨度替换为:

<span title="{{color}}" ng-style="{'background-color':color}">&nbsp;&nbsp;</span>

我不得不使用
ngattr样式

<div ng-attr-style="width: {{value}}%"></div>

这里有一个关于这个问题的例子


这是一个有更多解决方案的方法。

而不是
style=“background color:{{{color}};”
使用
ng style=“{'background-color':color}”
IE在angular还没有机会对其进行评估之前就删除了无效的样式值。这可能是重复的感谢,但我们需要一个开始引用,属性应为ng style=“{'background-color':color}”。我刚进入角度,看起来很兴奋。谢谢,我一定是打字太快了我添加了缺少的引用。正如在其他答案中提到的,这是一个Internet Explorer问题,而不是AngularJS问题。