我试图(失败)使用AngularModalService。从简单的教程做复制/粘贴作业给我一个错误。AngularJS角度模态服务给我一个错误
这是教程,以供参考: http://www.dwmkerr.com/the-only-angularjs-modal-service-youll-ever-need/
的Javascript:
var app = angular.module('app', ['angularModalService']);
app.controller('Controller', function($scope,ModalService) {
$scope.show = function() {
ModalService.showModal({
templateUrl: 'modal.html',
controller: "ModalController"
}).then(function(modal) {
modal.element.modal(); // this is the problem
modal.close.then(function(result) {
$scope.message = "You said " + result;
});
});
};
});
app.controller('ModalController', function($scope, close) {
$scope.close = function(result) {
close(result, 500);
};
});
</script>
HTML(在本教程的丑陋,而应该是简单)
<div class="container" style="min-width: 700px; max-width: 700px; margin: 50px auto;" data-ng-app="app" data-ng-controller="Controller">
<h3>Angular Modal Service</h3>
<a class="btn btn-default" href ng-click="show()">Show a Modal</a>
<p>{{message}}</p>
<!-- The html template -->
<script type="text/ng-template" id="modal.html">
<div class="modal fade">
<button type="button" ng-click="close('Cancel')" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Yes or No?</h4>
</div>
<div class="modal-body">
<p>It is your call...</p>
</div>
<div class="modal-footer">
<button type="button" ng-click="close('No')" class="btn btn-default" data-dismiss="modal">No</button>
<button type="button" ng-click="close('Yes')" class="btn btn-primary" data-dismiss="modal">Yes</button>
</div>
</script>
</div>
错误我在上面指出的线上获得“undefined不是函数”,即:
modal.element.modal();
谷歌搜索导致我没有具体的。希望我只是忽略了一些愚蠢的东西。
本教程采用了棱角分明1.2.9。你使用什么版本? – cgTag 2014-11-23 17:12:12
嗨 - 1.3.0-RC5。 – 2014-11-23 17:25:02