Javascript 在HTML与if/else statemets中的插值会产生AngularJS问题

Javascript 在HTML与if/else statemets中的插值会产生AngularJS问题,javascript,html,angularjs,Javascript,Html,Angularjs,我的看法是: <!doctype html> <html lang="en" ng-app="LunchCheck"> <head> <title>Lunch Checker</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="angular.min.js">

我的看法是:

<!doctype html>
<html lang="en" ng-app="LunchCheck">
  <head>
    <title>Lunch Checker</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="angular.min.js"></script>
    <script src="app.js"></script>"
    <link rel="stylesheet" href="styles/bootstrap.min.css">
    <style>
      .message { font-size: 1.3em; font-weight: bold; }
    </style>
  </head>
<body>
  <div class="container" ng-controller="LunchCheckController">
     <h1>Lunch Checker</h1>
     <div class="form-group" >
         <input id="lunch-menu" type="text"
             placeholder="list comma separated dishes you usually have for lunch"
             class="form-control" ng-model="input">
     </div>
     <div class="form-group">    
       <button class="btn btn-default" ng-click="stack()">
         Check If Too Much
       </button>
     </div>
     <div class="form-group message" id="result">
       <!-- Your message can go here. -->
       {{message}}
     </div>
  </div>

  </div>
  </div>
</body>
</html>
我是一个完全的初学者,但我不确定我做错了什么。抱歉,如果它很乱,我可能已经粘贴和编辑太多了

基本上,当我试图在浏览器中打开它时,我会在输入窗口下看到两个大括号,上面写着
{{message}

基本上,当我试图在浏览器中打开它时,我会在输入窗口下看到两个大括号,上面写着
{{message}

当您看到双花括号(
{{}}
)时,通常意味着没有加载AngularJS框架

检查开发人员控制台中的错误消息。

未捕获的语法错误:意外标记{app.js:20

问题出在第20行:

function LunchCheckController ($scope) {
    $scope.input = "";
    $scope.message = "";
    $scope.stack = function($scope, input) {

        var array = $scope.input.split(',');

        if (array.length <= 3) {
            $scope.message = "Enjoy";
        } else if (array.length > 3){
            $scope.message = "Please stop!";
        ̶}̶ ̶e̶l̶s̶e̶ ̶(̶$̶s̶c̶o̶p̶e̶.̶i̶n̶p̶u̶t̶ ̶=̶=̶ ̶"̶ ̶"̶ ̶|̶|̶ ̶N̶u̶l̶l̶ ̶)̶ ̶{̶
        } else {
            $scope.message = "Please enter something."
        }
    };
}          
功能控制器($scope){
$scope.input=“”;
$scope.message=“”;
$scope.stack=函数($scope,input){
var数组=$scope.input.split(',');
if(数组长度3){
$scope.message=“请停止!”;
7月7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7){
}否则{
$scope.message=“请输入一些内容。”
}
};
}          

else
不接受条件,使用:
else if…
该语句也可以改进:
else if(!$scope.input.trim()){//Do Stuff}
事件进一步,您可以设置
$scope.input
请在
IF
语句之前输入一些内容,然后去掉else。您可以显示您的配置吗?看看这个plunker示例,您将了解插值是如何发生的
else ($scope.input == " " || Null ) {
    $scope.message = "Please enter something."
}
function LunchCheckController ($scope) {
    $scope.input = "";
    $scope.message = "";
    $scope.stack = function($scope, input) {

        var array = $scope.input.split(',');

        if (array.length <= 3) {
            $scope.message = "Enjoy";
        } else if (array.length > 3){
            $scope.message = "Please stop!";
        ̶}̶ ̶e̶l̶s̶e̶ ̶(̶$̶s̶c̶o̶p̶e̶.̶i̶n̶p̶u̶t̶ ̶=̶=̶ ̶"̶ ̶"̶ ̶|̶|̶ ̶N̶u̶l̶l̶ ̶)̶ ̶{̶
        } else {
            $scope.message = "Please enter something."
        }
    };
}