2
我已經在線調查過這些信息,但無法使其正常工作。注入Angular 1.4.7 Cookie服務時出錯
我跟着這個在線文檔下方注入$cookies
服務爲我登錄控制器,但我不斷收到錯誤:[$injector:modulerr]
(function() {
'use strict';
angular.module('rage', ['ngCookies']).controller('LoginCtrl',
['$rootScope', '$scope', '$cookies', '$modalInstance', '$q', 'datacontext', 'userService', authenticate]);
function authenticate($rootScope, $scope, $cookies, $modalInstance, $q, datacontext, userService) {
var login = this;
// OK,CANCEL CLICK EVENTS FROM MODAL !!!
$scope.ok = function() {
var user = {userId: login.userId, pswd: login.pswd};
$modalInstance.close(user);
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
}
})();
我已經升級角從1.3.5到1.4.7,我的index.html有:
<!-- jQuery and Bootstrap -->
<script src="Scripts/jquery/jquery.min.js"></script>
<script src="Scripts/plugins/jquery-ui/jquery-ui.min.js"></script>
<script src="Scripts/bootstrap/bootstrap.min.js"></script>
<!-- Angular scripts-->
<!--<script src="Scripts/angular/angular-1.3.5.min.js"></script>-->
<script src="Scripts/angular/angular-1.4.7.min.js"></script>
<script src="Scripts/angular/angular-sanitize.min.js"></script>
<script src="Scripts/angular-ui-router/angular-ui-router.min.js"></script>
<script src="Scripts/angular/angular-cookies-1.4.7.min.js"></script>
<!-- angular-ui-bootstrap -->
<!--<script src="Scripts/bootstrap/ui-bootstrap-tpls-0.11.0.min.js"></script>-->
<script src="Scripts/bootstrap/ui-bootstrap-tpls-0.13.0.min.js"></script>
建議是極大的讚賞...
鮑勃
是真的!我從字面上只是發現了這一點,並下載了angular-cookies.js版本1.4.7,以便與Angular 1.4.7一致。儘管如此,我仍然試圖擺脫一些錯誤。 –
我想設置一個cookie過期,看來版本1.4.7有它,但沒有例子 - 即https://code.angularjs.org/1.4.7/docs/api/ngCookies/provider/ $ cookiesProvider。有任何想法嗎 ? –
var expireDate = expireDate = moment()。add(3,「month」).format(); $ cookie.put(「cookieName」,cookieString,{'expires':expireDate}); –