Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript angular$cookieStore在控制器$scope函数下不工作_Javascript_Angularjs_.htaccess_Angular Cookies - Fatal编程技术网

Javascript angular$cookieStore在控制器$scope函数下不工作

Javascript angular$cookieStore在控制器$scope函数下不工作,javascript,angularjs,.htaccess,angular-cookies,Javascript,Angularjs,.htaccess,Angular Cookies,我在使用angular js时遇到了一个问题 $locationProvider.html5Mode(true).hashPrefix('!'); 除了$cookieStore不能在控制器$scope中定义的函数下工作外,路由一切正常,这可能是因为我添加了.HTACCESS 我找不到任何解决方案,现在使用“window.localStorage”这里有人有解决方案吗 我的示例代码如下: HTML <button type="button" class="btn btn-default"

我在使用angular js时遇到了一个问题

$locationProvider.html5Mode(true).hashPrefix('!');
除了$cookieStore不能在控制器$scope中定义的函数下工作外,路由一切正常,这可能是因为我添加了.HTACCESS

我找不到任何解决方案,现在使用“window.localStorage”这里有人有解决方案吗

我的示例代码如下:

HTML

 <button type="button" class="btn btn-default" ng-click='doLogin()'>Sign in</button>
})

.HTACCESS

#BEGIN
Options +FollowSymLinks

<ifModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^ index.html [L]
</ifModule>

#END
#开始
选项+FollowSymLinks
重新启动发动机
RewriteCond%{REQUEST_FILENAME}-f[或]
RewriteCond%{REQUEST_FILENAME}-d
重写规则^-[L]
重写规则^index.html[L]
#结束

我现在遇到了这个问题。你的帖子给我指出了正确的问题。 我创建了一个plnkr来尝试重新编程,并注意到我能够在$scope方法中很好地执行$cookieStore.put()。 因此,问题似乎在于源文件的verisoning。我对angular.js和angular-cookies.js使用了1.3.11,但对angular-route.js使用了1.3.5

修复方法是将1.3.11用于angular-route.js或您正在使用的相应版本

#BEGIN
Options +FollowSymLinks

<ifModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^ index.html [L]
</ifModule>

#END