Angular与控制器的智能问题

时间:2015-08-08 10:09:51

标签: angularjs intellij-idea

我开始学习angularJs(刚刚开始)。 我在intelliJ(静态Web)中开了一个新项目。

代码:

<!DOCTYPE html>
<html data-ng-app="">
<head lang="en">
    <meta charset="UTF-8">
    <title>Using Angularjs Directive and Data Binding</title>
</head>
<body>
<div ng-controller="SimpleController">
Name:
<br />
    <input type="text" ng-model="name"/>
</br>
<ul>
    <li ng-repeat="cust in customers | filter:name | order">{{ cust.name}}-{{cust.city}}</li>
</ul>
</div>
<script src="Scripts/angular.min.js"></script>
<script>
    function SimpleController($scopecust){
        $scopecust.customers= [
            {name:'John Smith', city:'Barca'},{name:'John Snow', city:'winterfull'},{name:'John Do', city:'milan'}
        ];
    }
</script>
</body>
</html>

出于某种原因,我猜控制器没有绑定..我在网页上看到的只是带输入字段的名称

1 个答案:

答案 0 :(得分:0)

因为你的Js中没有textareamessage = new JTextArea( "Welcome to the #BallIsLife Chat room.\n"); textareamessage.setFont(new Font("Monospaced", Font.PLAIN, 15)); textareamessage.setLineWrap(true); textareamessage.setEditable(false); JPanel centerPanel = new JPanel(new GridLayout(1, 1)); JScrollPane scrollPane = new JScrollPane(textareamessage); centerPanel.add(scrollPane); getContentPane().add(centerPanel, BorderLayout.CENTER); 首先,您需要定义一个模块,然后定义控制器,如下所示:

SimpleController

现在将模块的名称放在var app=angular.module('myModule',[]) app.controller('simpleController',function($scope){ $scope.customers= [ {name:'John Smith', city:'Barca'}, {name:'John Snow', city:'winterfull'},{name:'John Do', city:'milan'} ]; }); 中,如:

<html>