AuthService is not available in AppCues for AngularJS - angularjs

I am new to Appcues development and referring to the example given in this page for AngularJS.
Appcues Example for AngularJS
I noticed that the AuthService is being used in the controller code but the AuthService is not provided anywhere. Due to this, the code is unable to infer the AuthService and it is not possible to load the page.
Could anyone suggest how AuthService should be inferred so that the page can be rendered?
Please let me know if I need to provide any specific details.
Thanks,
Ramesh, INDIA

Your syntax for the controller is wrong, it should be, Remove the extra ) after the controller name
.controller('LoginController',function($scope,$rootScope,AUTH_EVENTS,AuthService){
}

Related

Confirm password in Angular JS

https://embed.plnkr.co/oCd2WrzJjFtvgsGdHrdV3b/
Hello , I created Login page and Register page. But I need to add an additional functionality of confirm password. I am pretty confused in handling this with my controllers.
can anyone help me in validation part.
When I give Ng-match or directives , it is not compatible with my existing controller. Either it states Registration successful in case of wrong password or else my view is just empty in browser.
Use following ng-match directive
http://ngmodules.org/modules/ng-match
plnkr.co/edit/LRXKpql1AxmGNcTWifGS?p=preview
I solved the issue you faced with confirmPassword. I'm just
saying where you made the mistake
1)password name in ng-modal and name in "required data-password-verify" at confirm password should match when you compare two passwords.
2)Please have a look at console first,then you understand where you did a mistake.Console clearly saying two issues i.e app is not defined at passwordVerify.js and User service not defined.
3)I changed passwordVerfiy directive to register controller and I commented userservice wherever i find.Because I have not seen anywhere you are using Userservice class.Both the files(user.service and user.service,localstorage) are empty
I would be more happy if my code resolve your problem.
Thank you

Can I run a function instead of routing on otherwise in Angular?

As my question asks, I want to know if that is possible. Why I want this? I am required to keep the link when the request fails so I use states in my bootstrap template instead of templates for the error pages. Now I need to catch everything that isn't registered and I need to tell my main controller to change the state if the route is not found. I checked the documentation, of course but it hasn't enlightened me so please help me out here if you can.
$httpProvider.otherwise(function () {
// code here
});
Is something like this possible?

Where to implement Restangular's Extend Model

I'm currently migrating my application from $resouce to Restangular and I'm having trouble understanding where extendModel should be implemented.
Having read through the slides available here on slide 46 it shows the following two snippets.
Restangular.extendModel('cars', function(car){
return Car.extend(car);
});
module.factory('Car', function(Exteder){
function Car(){}
Car.prototype.chargeFuel = function(amount){
}
Car.extend = Extender.for('car')
return Car
});
My question is where should the extendModel function actually be declared? Should it be in the App.config or in a controller somewhere? I've been through the documentation several times now and I can't seem to find a concrete answer.
So after much searching I believe I've found the correct place to implement this as being in the app.config section of the angular application.
Simply pass the RestangularProvider as a parameter and use RestangularProvider.extendModel()

How to return/edit REST resource with AngularJS & Restangular

Using Restangular for AngularJS, keep getting an object object from Mongolab.
I'm sure it has to do with Promise but not sure how to use/implement this coming from old Java OO experience.
(Side note, would something like Eloquent Javascript, some book or resource help me understand the 'new' Javascript style?)
The small web app is for Disabled Students and is to input/edit the students, update the time they spend after school and then output reports for their parents/caregivers every week.
Here's the code that returns undefined when popping up a new form (AngularJS Boostrap UI modal)
I personally think Restangular & the documentation is a great addition so hope it doesn't dissuade others - this is just me not knowing enough.
Thanks in advance
app.js
...
$scope.editStudent = function(id) {
$scope.myStudent = Restangular.one("students", id);
console.log($scope.myStudent);
}
I'm the creator of Restangular :). Maybe I can help you a bit with this.
So, first thing you need to do is to configure the baseUrl for Restangular. For MongoLab you usually do have a base url that's similar to all of them.
Once you got that working, you need to check the format of the response:
If your response is wrapped in another object or envelope, you need to "unwrap" it in your responseExtractor. For that, check out https://github.com/mgonto/restangular#my-response-is-actually-wrapped-with-some-metadata-how-do-i-get-the-data-in-that-case
Once you got that OK, you can start doing requests.
All Restangular requests return a Promise. Angular's templates are able to handle Promises and they're able to show the promise result in the HTML. So, if the promise isn't yet solved, it shows nothing and once you get the data from the server, it's shown in the template.
If what you want to do is to edit the object you get and then do a put, in that case, you cannot work with the promise, as you need to change values.
If that's the case, you need to assign the result of the promise to a $scope variable.
For that, you can do:
Restangular.one("students", id).get().then(function(serverStudent) {
$scope.myStudent = serverStudent;
});
This way, once the server returns the student, you'll assign this to the scope variable.
Hope this helps! Otherwise comment me here!
Also check out this example with MongoLab maybe it'll help you :)
http://plnkr.co/edit/d6yDka?p=preview

Setting permissions in cakephp Pages controller

I followed Andrew Perkins excellent tutorial on setting up permissions in CakePHP 2.0.
My question, however, relates to how to use the allow and deny method in the Pages controller. Currently I have $this->Auth->allow('display') which allows all methods in the Pages controller to be view.
What if I only want the home page allowed but the rest denied? How do I code that?
Thanks in advance.
Make sure you have copied the PageController.php to your app/Controller folder. Then, add a beforeFilter callback method and set access based on the passed page parameter:
public function beforeFilter() {
// Use $this->request->pass to get the requested page name/id
// Decide on access with $this->Auth->allow()
}
This should solve your problem.
You can find more information on request's lifecycle in CakePHP manual. That's pretty useful stuff.
Have you tried this code?
You can out it into your PageController or into your Controller directly
$views = array ('index'); //array of view that you want allow
$this->Auth->allow($views);

Resources