gpt4 book ai didi

javascript - Bootstrap 和 AngularJS 简单代码

转载 作者:行者123 更新时间:2023-11-27 23:47:55 24 4
gpt4 key购买 nike

大家好,我有一个使用 Bootstrap 和 AngularJS 的简单代码,但我似乎无法处理。单击按钮后,它只会显示警报。这是代码:

var myapp = angular.module('myapp',['ui.bootstrap']);

myapp.controller('mainCtrl', ['$scope',mainCtrl]);

function mainCtrl($scope) {
$scope.testing = function() {
alert("Button Is Pressed");
}
}
<!DOCTYPE html>
<html lang="en-US" data-ng-app="myapp">
<head>
<title>Sample Angular JS</title>

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<script type='text/javascript' src='https://github.com/angular-ui/bootstrap/blob/gh-pages/ui-bootstrap-0.11.2.min.js'></script>
<script type='text/javascript' src='https://code.angularjs.org/1.3.0-rc.1/angular.min.js'></script>

<script type='text/javascript' src='myapp.js'></script>

</head>

<body data-ng-controller="mainCtrl">

<div class="container">
<button class="navbar-btn btn-danger btn pull-right" data-ng-click="testing()">Test</button>
</div>

</body>
</html>

我不确定为什么该按钮不起作用,是否是由于我正在使用的库所致?请告知我是 AngularJS 框架的新手。谢谢。

最佳答案

ui-bootstrap 需要 bootstrap,而 bootstrap 需要 jQuery...您将收到一个依赖项错误,导致无法正常工作...

关于javascript - Bootstrap 和 AngularJS 简单代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32989296/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com