angular.js提示控制器未注册

HelloBitches HelloBitches 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

function commonController($scope){
$scope.commonFn = function(){
alert('这里是公共功能');
}
}

function controller1($scope){
$scope.greeting = {
text:'hello1'
}

$scope.test1 = function(){
alert('test1');
}
}

function controller2($scope){
$scope.greeting = {
text:'hello2'
}

$scope.test2 = function(){
alert('test2');
}
}





<!DOCTYPE html>
<html ng-app>
<head>
<meta charset="UTF-8">
<title>ng model</title>
<script src="lib/angular.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/common.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div ng-controller="commonController">
<div ng-controller='controller1'>
<p>
{{greeting.text}},angular
</p>
<button ng-click='test1()'>test1</button>
</div>
<div ng-controller='controller2'>
<p>
{{greeting.text}},angular
</p>
<button ng-click='test2()'>test2</button>
</div>
<button ng-click='commonFn()'>通用</button>
</div>
</body>
</html>

...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
HelloBitches
JavaScript 87,983 成员 224,680 内容