为什么我的angularjs项目中会出现语法错误

时间:2016-06-12 19:03:55

标签: javascript html css angularjs

在我的angularJS项目中,我遇到了错误。你能帮我吗?

错误

angular.min.js:117错误:[$ parse:syntax] http://errors.angularjs.org/1.5.6/ $ parse / syntax?p0 = Shoping& p1 = is%20an%20unexpected%20token& p2 = 8& p3 = Online%20Shoping %20-%20login&安培; P4 = SHOPING%20-%20login     在错误(本机)     在localhost:8082 / onlineshopping / angular.min.js:6:412     在Object.s.throwError(localhost:8082 / onlineshopping / angular.min.js:228:143)     在Object.s.ast(localhost:8082 / onlineshopping / angular.min.js:220:47)     在Object.td.compile(localhost:8082 / onlineshopping / angular.min.js:229:420)     在kc.parse(localhost:8082 / onlineshopping / angular.min.js:258:213)     at g(localhost:8082 / onlineshopping / angular.min.js:125:278)     在k(localhost:8082 / onlineshopping / angular.min.js:105:129)     at $(localhost:8082 / onlineshopping / angular.min.js:77:397)     在$ b(localhost:8082 / onlineshopping / angular.min.js:61:398)

  

我的HTML代码

<!DOCTYPE html>
<html>
<head>
<title>Online Shopping - Login Page</title>
<script src="angular.min.js"></script>
<!-- <link rel="stylesheet" href=".\WEB-INF\lib\css\Styles.css"/> -->
</head>
<body ng-app>
    <div style="text-align:center">
        <h1>{{Online Shoping - login}}</h1>
        <form action="login_submit" name="login" method="get">
            Email Address: <input type="email" placeholder="username@mail.com" required/><br><br>
            Password: <input type="password" placeholder="password" required/><br><br><br>
            <input type="submit" value="Login"/>
        </form>
    </div>
</body>
</html>

2 个答案:

答案 0 :(得分:1)

您只需要像

那样更新<h1></h1> tage
 <h1>Online Shoping - {{login}}</h1>

或者您也可以使用<h1></h1>之类的

{{'Online Shopping - '+ login}}

有关详细信息,请点击fiddler Here

答案 1 :(得分:0)

这是错误的{{Online Shoping - login}},因为Online Shoping不是值也不是有效语法。您可以使用字符串并连接值:

{{'Online Shopping - '+ login}}

或者只是在需要的地方进行插值:

<h1>Online Shopping - {{login}}</h1>