Hi,
Not sure why you can't see the example - is your firewall blocking plnkr.co?
Here's the code:
*app.js*
var app = angular.module('plunker', ['ngCookies']);
app.controller('MainCtrl', function($scope, $cookies) {
$scope.data = {};
// the name
$scope.data.name = $cookies.myFavorite;
// for the input box
$scope.data.inputValue = $cookies.myFavorite;
// Setting a cookie
$scope.saveCookie = function() {
$cookies.myFavorite = $scope.data.favorite;
}
});
On Wednesday, 21 January 2015 08:45:54 UTC+2, [email protected]
wrote:
>
> Hi Justin
>
> I can not open the example:http://plnkr.co/edit/yau1iT?p=preview .Would
> you help me by other ways?
>
> Regards
> James
>
> On Wednesday, January 21, 2015 at 2:13:54 PM UTC+8, Justin Walsh wrote:
>>
>> Hi James
>>
>> Here is a very simple example: http://plnkr.co/edit/yau1iT?p=preview
>> which demonstrates the saving of a cookie.
>>
>> The first time you visit the page you won't have a cookie. Typing
>> something into the input box and clicking the button will save your cookie.
>> Then, refreshing the page (or stop and start the punkr) and you will see
>> the value of the cookie after the 'Hello' text. This demonstrates that the
>> cookie is in fact being saved.
>>
>> Does this work for you? Perhaps the file based manner in which you seem
>> to be creating your app is a problem?
>>
>> Regards
>> Justin
>>
>>
>>
>> On Wednesday, 21 January 2015 05:01:42 UTC+2, [email protected]
>> wrote:
>>>
>>>
>>> <https://lh6.googleusercontent.com/-CL47T2gp414/VL8WcepREXI/AAAAAAAAAAM/WrTdc9wZfN4/s1600/piccc.png>
>>> Hi boys:
>>>
>>> The version of angular that i used is v1.3.4.The code i used
>>> like this .
>>> <script src="angular.js"></script>
>>> <script src="angular-cookies.js"></script>
>>>
>>> <script>
>>>
>>> angular.module('validateApp', ['ngCookies'])
>>> .controller('validateCtrl', ['$cookies', function($cookies) {
>>> // Retrieving a cookie
>>> var favoriteCookie = $cookies.myFavorite;
>>> // Setting a cookie
>>> $cookies.myFavorite = 'oatmeal';
>>> }]);
>>> </script>
>>>
>>> but ,when i press F12 in the chrome browser,i can not
>>> find the result in the browser.
>>>
>>>
>>> <https://lh6.googleusercontent.com/-CL47T2gp414/VL8WcepREXI/AAAAAAAAAAM/WrTdc9wZfN4/s1600/piccc.png>
>>>
>>> Who can help me ??
>>>
>>>
>>>
>>>
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.