多个控制器不在angularjs中工作

KVK*_*KVK 3 jsp angularjs

我是棱角分明的新手.我写代码执行多个控制器概念,但它不工作.我不知道我在哪里做错了?

以下代码我正在使用

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html >
<html>
<head>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body ng-app="myApp">

<div ng-controller="myCtrl">
<input type="number" ng-model="q">
<input type="number" ng-model="c">
<p>{{ q*c }}</p>
</div>

<div ng-controller="newone">
<p>{{lastName|uppercase}}</p>

</div>




</body>


<script>
var app=angular.module('myApp',[]);
app.controller('myCtrl',function($scope)
{
    $scope.q=10;
    $scope.c=5;

    });
</script>
<script src="control.js"></script>
</html>



**control.js**

var app=angular.module('myApp',[]);
app.controller('newone',function($scope){
    alert();
    $scope.firstName="Vinoth";
    $scope.lastName="Kumar";
    $scope.full=function()
    {
        return $scope.firstName+''+$scope.lastName;
    }

});
Run Code Online (Sandbox Code Playgroud)

以上代码不起作用任何人都可以帮我解决这个问题

squ*_*oid 5

在controller.js中,您不需要再次声明模块:)

var app=angular.module('myApp',[]);
Run Code Online (Sandbox Code Playgroud)

改为 var app=angular.module('myApp');