大家好我正在尝试将基本示例从angular连接到cookie但是只要我导入cookie它就不会工作。请看这个jsfiddle:https://jsfiddle.net/y7dxa6n8/
这就是它的样子:
<script>
var myApp = angular.module('myApp', ['ngCookies']);
myApp.controller('MyController', ['$cookies', function($cookies) {
this.u = 'rawr';
}]);
</script>
<div ng-app="myApp">
<div ng-controller="MyController as mc">
<label>Name:</label>
<input type="text" ng-model="mc.u" placeholder="Enter a name here">
<hr>
<h1>Hello {{mc.u}}!</h1>
</div>
</div>
答案 0 :(得分:2)
您需要添加脚本angular-cookies.js的链接,即将<script src="angular-cookies.js">
添加到您的页面。这在Angular documentation
以下是更新且有效的jsFiddle