最佳答案
因为当你执行var new = angular.module(‘myapp’,[])时,你会覆盖第一个myapp模块;
原文链接:https://www.f2er.com/html/426583.html你的代码应该是:
var app = angular.module("myapp",[]);
app.controller('cont1',function($scope) {
$scope.fullname = "";
});
app.controller('cont2',function($scope) {
$scope.fname = "";
});
要么
var app = angular.module("myapp",function($scope) {
$scope.fullname = "";
});
angular.module("myapp").controller('cont2',function($scope) {
$scope.fname = "";
});
传递给module()的第二个参数[]产生了不同