[英]Double brackets not registering in Angular.js html
I just recently learned angular.js (and i use the word "learned" loosely), and I am trying to make a basic website and have gotten stuck on form validation. 我最近才学到angular.js(并且我宽松地使用了“ learned”一词),并且我试图建立一个基本的网站,并且陷入了表单验证的困境。 I realized that the double bracket notation I learned from "Shaping up with angular.js" isn't registering on the webpage that I have.
我意识到,我从“用angular.js进行造型”中学到的双括号符号没有在我拥有的网页上注册。 I've been hacking at this all day and you'll probably see more than a few issues with my code (feel free to comment).
我整天都在进行骇客攻击,您的代码可能会看到多个问题(随意发表评论)。
The code piece I am talking about is this: 我正在谈论的代码段是这样的:
<div class="divvy" ng-repeat="slider in main.sliders">
<h3>
{{slider.name}} costs {{slider.cost | currency}}
</h3>
</div>
I will include the entire code, but for reference, the class "divvy" is just a convoluted way to make the div centered on the screen. 我将包括整个代码,但作为参考,“ divvy”类只是使div集中在屏幕上的一种复杂方法。 My header reads as this:
我的标题是这样的:
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<link href="https://fonts.googleapis.com/css?family=Didact+Gothic|Ek+Mukta|Montserrat" rel="stylesheet">
<script type="text/javascript" src="script.js"></script>
<script type="text/javascript" src="//code.angularjs.org/snapshot/angular.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
And the script.js file is rather simple, because I haven't really done anything with it yet besides debugging why this isn't working. 而且script.js文件非常简单,因为除了调试为什么它不起作用之外,我还没有真正对其进行任何处理。
(function(){
var app = angular.module("myModule",[]);
app.controller('MainController',function(){
this.products= sliders;
});
var sliders= [
{name: "Charles",
cost: "4.20"
},
{
name:"Alfred",
cost:"30"
},
{
name:"Something that costs 10 bucks",
cost:"10.1"
}
]
})()
Please help me out. 请帮帮我。 I think that something else I was trying to fix made it so that I couldn't use angular properly anymore (there is a button in there that is meant to edit text (also a debugging attempt) and it used to work but no longer does after some ctrl+z made me lose my place).
我认为我正在尝试修复的其他问题使它无法再正确使用angular(那里有一个用于编辑文本的按钮(也是调试尝试),它曾经可以工作,但不再起作用经过一些ctrl + z使我失去位置)。 Additionally, if you have extra time, there is a background picture which I spent a lot of time figuring out how to center and make it "zoom-proof", but I would like to edit it dynamically (background changes with slides or fadechanges) but the background img is stuck in style.css html{}... And I don't know how to edit that using "myStyle" or even use ng-myStyle in the first place.
另外,如果您有多余的时间,则有一张背景图片,我花了很多时间弄清楚如何居中并使其“防变焦”,但我想动态地对其进行编辑(背景变化(带有幻灯片或淡入淡出的变化))但是背景img卡在style.css html {}中...而且我不知道如何使用“ myStyle”进行编辑,或者甚至不使用ng-myStyle。 Thank you.
谢谢。 The full code is at plunker, here: https://plnkr.co/edit/H4uhcU
完整的代码在plunker上,在这里: https ://plnkr.co/edit/H4uhcU
It should be, 它应该是,
<div class="divvy" ng-repeat="slider in main.products">
DEMO 演示
var app = angular.module("myModule",[]); app.controller('MainController',function(){ var sliders= [ {name: "Charles", cost: "4.20" }, { name:"Alfred", cost:"30" }, { name:"Something that costs 10 bucks", cost:"10.1" }]; this.products= sliders; });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <body ng-app= "myModule" ng-controller="MainController as main"> <div class="divvy" ng-repeat="slider in main.products"> <h3> {{slider.name}} costs {{slider.cost | currency}} </h3> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.