Search Results

Search found 169 results on 7 pages for 'angularjs'.

Page 5/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • angular custom directive required validation is not updated

    - by Wouter Willems
    i created my own directive, replacing an input field with a custom made input field. However, the validation of the required field never seems to update and instead is always false. Other directives inside my directive like ng-class do work. I have created a plunker here to show this problem: http://plnkr.co/edit/NuZNAJceL0MVX8i6RK9n?p=preview Can anybody help me out how to make sure that the required validation is properly updated?

    Read the article

  • ngModel and component with isolated scope

    - by Artem Andreev
    I am creating simple ui-datetime directive. It splits javascript Date object into _date, _hours and _minutes parts. _date uses jquery ui datepicker, _hours and _minutes - number inputs. See example: http://jsfiddle.net/andreev_artem/nWsZp/3/ On github: https://github.com/andreev-artem/angular_experiments/tree/master/ui-datetime As far as I understand - best practice when you create a new component is to use isolated scope. When I tried to use isolated scope - nothing works. ngModel.$viewValue === undefined. When I tried to use new scope (my example, not so good variant imho) - ngModel uses value on newly created scope. Of course I can create directive with isolated scope and work with ngModel value through "=expression" (example). But I think that working with ngModelController is a better practice. My questions: Can I use ngModelController with isolated scope? If it is not possible which solution is better for creating such component?

    Read the article

  • How can I match a twitter username with angular ui router

    - by user3929999
    I need to be able to match a path like '/@someusername' with angular ui router but can't figure out the regex for it. What I have are routes like the following $stateProvider .state('home', {url:'/', templateUrl:'/template/path.html'}) .state('author', {url:'/{username:[regex-to-match-@username-here]}'}) .state('info', {url:'/:slug', templateUrl:'/template/path.html'}) .state('entry', {url:'/:type/:slug', templateUrl:'/template/path.html'}); I need a bit of regex for the 'author' route that will match @usernames. Currently, everything I try is caught by the 'entry' route.

    Read the article

  • Nested ng repeat not working

    - by Rodrigo Fonseca
    Ok, i've two ng-repeat working here, the first(board in boards) is working good, no problem, but the second(task in tasks), when i try to get "{{task.title}}" i don't get anything but i can display all the style from it... here is my model: $scope.tasks = [{boardIndex: 0, title: "test"}, {boardIndex: 1, title: "test2"}]; Here is my code(it's in jade, ok?) section(data-ng-repeat="board in boards", ng-cloak) .board_header div(data-ng-controller="AddTaskBtnController") i.add_task_btn.fa.fa-plus-square-o.fa-2x(ng-click='setSelected(board.id)', ng-class="{icon_add_hover: isSelected(board.id)}") h2(data-ng-bind="board.title") .content_board .task(data-ng-repeat="task in tasks", data-ng-if="task.boardIndex == board.id", data-ng-controller='TaskController', data-ng-hide='modeTask', data-ng-init='setTaskId()') .user_icon_task i.fa.fa-user.fa-3x.icon-user-not-selected .quest_task .puzzle_task(data-ng-hide='modeTask') i.fa.fa-check-circle-o.fa-lg h2 {{task.title}} ul.icons_details_task_wrapper li i.fa.fa-check-circle-o span.icon_counter li.pull_left i.fa.fa-puzzle-piece span.icon_counter ul.task_details_wrapper li.task_priority(data-ng-show='goal.selectedDrawAttention', data-ng-click='toggleSelected()', data-ng-class='{draw_attention_selected: goal.selectedDrawAttention }', style='cursor: inherit;') i.fa.fa-eye li.task_priority i.fa .task_time_ago span(am-time-ago='message.time')

    Read the article

  • How to change scope data in controller?

    - by Derooie
    I am a real newbie at angular. I created something now which will let me retrieve and add items via angular and get/put them in mongodb. I use express and mongoose in the app The question is, how can i modify the data before it reaches the DOM in the controller. In this example i have created a way to retrieve data, and i get it exactly as it is stored in mongodb. What i would like is that the field where i store 1 or 0 in the database, to be shown as text. So if mongo has a value 1 i get "the value in mongo is 1" and when the field has a value of 0 get "the value is zero". (just as an example, i like other texts, but it illustrate what i want) I post my controller, html and current output. Any help would be appreciated. Controller function getGuests($scope, $http) { $scope.formData = {}; $http.get('/api/guests') .success(function(data) { $scope.x = data; }) .error(function(data) { console.log('Error: ' + data); }); } HTML <div ng-controller="getGuests"> <div ng-repeat="guest in x"> {{ guest.voornaam }} {{ guest.aanwezig }} </div> </div> The current scope output, what i see in HTML. I like to change only the value of "aanwezig" in case the value of aanwezig is 0 or 1. firstname1 1 firstname2 0 Something else, but would be great to learn, is how i can do a specific mongodb query by the push of a button and get that result.

    Read the article

  • Angular ng-style not changing with property

    - by ganaraj
    For the life of me I cant seem to figure out why the style property is not getting updated. In my larger application it seems to work fine. http://jsfiddle.net/ganarajpr/C2hRa/4/ Here is a fiddle which shows the issue I am currently facing. You will notice that the width and height are getting updated in the div when you change the input. But the style itself doesnt seem to be updating. Anyone can tell me what I am doing wrong here? I have tried all the following scenarios using $scope.$apply.. - Throws an error stating $apply already in progress.. $rootScope.$apply - same as above. Setting another variable in a service which is $watched in the other controller. - no change seen. It would be really cool if someone can get me an answer to this. Also would be really happy if you can tell me why exactly it is not getting updated.

    Read the article

  • Running mysql query using node blocks the whole process and then timesout

    - by lobengula3rd
    I have a node javascript that uses mysql npm (Felix). I have a procedure stored in my DB which I call when the user selects an option to kind of create its own instance of the program. The user chooses for how long he wants that data to be initialized for him. This is suppsoed to be between 1 and 2 years. So if he choose 1 year this query will insert around 20,000 rows into 1 table. If I run this query and a local DB this takes around 30 seconds (I suppose it is reasonable because its a big query which should be done only once in 1 or 2 years so its ok). For some reason my node script freezes as if it can't handle any more calls from other users. The even worse problem is that after like 2 minutes my client ui gets like an error from the server. At this point not all the data that was supposed to enter the DB is entered. After waiting like another minute all the data finally gets to the DB and only then it will accept new requests. This is my connection: this.connection = mysql.createConnection({ host : '********rds.amazonaws.com', user : 'admin', password : '******', database : '*****' }); and this is my query function: this.createCourts = function (req, res, next){ connection.query('CALL filldates("' + req.body['startDate'] + '","' + req.body['endDate'] + '","' + req.body['numOfCourts'] + '","' + req.body['duration'] + '","' + req.body['sundayOpen'] + '","' + req.body['mondayOpen'] + '","' + req.body['tuesdayOpen'] + '","' + req.body['wednesdayOpen'] + '","' + req.body['thursdayOpen'] + '","' + req.body['fridayOpen'] + '","' + req.body['saturdayOpen'] + '","' + req.body['sundayClose'] + '","' + req.body['mondayClose'] + '","' + req.body['tuesdayClose'] + '","' + req.body['wednesdayClose'] + '","' + req.body['thursdayClose'] + '","' + req.body['fridayClose'] + '","' + req.body['saturdayClose'] + '");', function(err){ if (err){ console.log(err); } else return res.send(200); }); }; what am i missing here? as i understand connection.query should by async so why is it actually blocking my node script? thanks.

    Read the article

  • Route Angular to New Controller after Login

    - by MizAkita
    I'm kind of stuck on how to route my angular app to a new controller after login. I have a simple app, that uses 'loginservice'... after logging in, it then routes to /home which has a different template from the index.html(login page). I want to use /home as the route that displays the partial views of my flightforms controllers. What is the best way to configure my routes so that after login, /home is the default and the routes are called into that particular templates view. Seems easy but I keep getting the /login page when i click on a link which is suppose to pass the partial view into the default.html template: var app= angular.module('myApp', ['ngRoute']); app.config(['$routeProvider', function($routeProvider) { $routeProvider.when('/login', { templateUrl: 'partials/login.html', controller: 'loginCtrl' }); $routeProvider.when('/home', { templateUrl: 'partials/default.html', controller: 'defaultCtrl' }); }]); flightforms.config(['$routeProvider', function($routeProvider){ //sub pages $routeProvider.when('/home', { templateUrl: 'partials/default.html', controller: 'defaultCtrl' }); $routeProvider.when('/status', { templateUrl: 'partials/subpages/home.html', controller: 'statusCtrl' }); $routeProvider.when('/observer-ao', { templateUrl: 'partials/subpages/aobsrv.html', controller: 'obsvaoCtrl' }); $routeProvider.when('/dispatch', { templateUrl: 'partials/subpages/disp.html', controller: 'dispatchCtrl' }); $routeProvider.when('/fieldmgr', { templateUrl: 'partials/subpages/fieldopmgr.html', controller: 'fieldmgrCtrl' }); $routeProvider.when('/obs-backoffice', { templateUrl: 'partials/subpages/obsbkoff.html', controller: 'obsbkoffCtrl' }); $routeProvider.when('/add-user', { templateUrl: 'partials/subpages/users.html', controller: 'userCtrl' }); $routeProvider.otherwise({ redirectTo: '/status' }); }]); app.run(function($rootScope, $location, loginService) { var routespermission=['/home']; //route that require login $rootScope.$on('$routeChangeStart', function(){ if( routespermission.indexOf($location.path()) !=-1) { var connected=loginService.islogged(); connected.then(function(msg) { if(!msg.data) $location.path('/login'); }); } }); }); and my controllers are simple. Here's a sample of what they look like: var flightformsControllers = angular.module('flightformsController', []); flightforms.controller('fieldmgrCtrl', ['$scope','$http','loginService', function($scope,loginService) { $scope.txt='You are logged in'; $scope.logout=function(){ loginService.logout(); } }]); Any ideas on how to get my partials to display in the /home default.html template would be appreciated.

    Read the article

  • Debugging Post Request with Chrome Dev Tools

    - by benek
    I am trying to use Chrome Dev for debugging the following Angular post request : $http.post("http://picjboss.puma.lan:8880/fluxpousse/api/flow/createOrUpdateHeader", flowHeader) After running the statement with right-click / evaluate, I can see the post in the network panel with a pending state. How can I get the result or "commit" the request and leave easily this "pending" state from the dev console ? I am not yet very familiar with JS callbacks, some code is expected. Thanks. EDIT I have tried to run from the console : $scope.$apply(function(){$http.post("http://picjboss.puma.lan:8880/fluxpousse/api/flow/createOrUpdateHeader", flowHeader).success(function(data){console.log("error "+data)}).error(function(data){console.log("error "+data)})}) It returns : undefined EDIT The post I am trying to solve generate an HTTP 400. Here is the result : Request URL:http://picjboss.puma.lan:8880/fluxpousse/api/flow/createOrUpdateHeader Request Method:POST Status Code:400 Mauvaise Requ?te Request Headersview source Accept:application/json, text/plain, / Accept-Encoding:gzip,deflate,sdch Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4 Connection:keep-alive Content-Length:5354 Content-Type:application/json;charset=UTF-8 Cookie:JSESSIONID=285AF523EA18C0D7F9D581CDB2286C56 Host:picjboss.puma.lan:8880 Origin:http://picjboss.puma.lan:8880 Referer:http://picjboss.puma.lan:8880/fluxpousse/ User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36 X-Requested-With:XMLHttpRequest Request Payloadview source {refHeader:IDSFP, idEntrepot:619, codeEntreprise:null, codeBanniere:null, codeArticle:7,…} cessionPrice: 78 codeArticle: "7" codeBanniere: null codeDateAppro: null codeDateDelivery: null codeDatePrepa: null codeEntreprise: null codeFournisseur: null codeUtilisateur: null codeUtilisateurLastUpdate: null createDate: null dateAppro: null dateDelivery: null datePrepa: null hasAssortControl: null hasCadenceForce: null idEntrepot: 619 isFreeCost: null labelArticle: "Mayonnaise de DIJON" labelFournisseur: null listDetail: [,…] pcbArticle: 12 pvc: 78 qte: 78 refCommande: "ref" refHeader: "IDSFP" state: "CREATED" stockArticle: 1200 updateDate: null Response Headersview source Connection:close Content-Length:996 Content-Type:text/html;charset=utf-8 Date:Fri, 08 Nov 2013 15:19:30 GMT Server:Apache-Coyote/1.1 X-Powered-By:Servlet 2.5; JBoss-5.0/JBossWeb-2.1

    Read the article

  • angular bootstrap typeahead bug

    - by Mohammad Akbari
    i use angular bootstrap typeahead (this lib ui-bootstrap-tpls.js ) in my app, when use two typeahead in one scope, only one work well, and other not work, this is my code angular.module('plunker', ['ui.bootstrap']); function TypeaheadCtrl($scope) { $scope.selected = undefined; $scope.selected2 = undefined; $scope.states = ['Alabama', 'Alaska','California', 'Hawaii', 'Wisconsin', 'Wyoming']; } <html ng-app="plunker"> <head> <title></title> <link href="lib/angular-bootstrap/bootstrap.css" rel="stylesheet" /> <script src="lib/angular/angular.js"></script> <script src="lib/angular-bootstrap/ui-bootstrap-tpls-0.3.0.min.js"></script> <script src="app.js"></script> </head> <body> <div class='container-fluid' ng-controller="TypeaheadCtrl"> <pre>Model: {{selected| json}}</pre> <input type="text" ng-model="selected" typeahead="state for state in states | filter:$viewValue"> <input type="text" ng-model="selected2" typeahead="state for state in states | filter:$viewValue"> </div> </body> please check this and help.

    Read the article

  • Can't get Angular Dart Router to work

    - by JesterXL
    I've tried this syntax in AngularDart 0.11.0: Angular Dart passing data from route service into a controller module.value(RouteInitializerFn, configureRoutes); void configureRoutes(Router router, RouteViewFactory views) { print("configureRoutes"); views.configure({ 'login': ngRoute( path: '/login', view: 'login/login.tpl.html'), 'today': ngRoute( path: '/today', view: '/today/today.tpl.html') }); However, my routing function never seems to get called. I've used both a print statement and breakpoint to no avail. When I attempt to call it like so: WorkoutLoggerApplication(this.rootScope, this.router) { print("WorkoutLoggerApplication::constructor"); new Future.delayed(new Duration(seconds: 2), () { router.go("login", {}); }); } I get: Bad state: Invalid route name: login I've tried 0.10.0, but no dice. I've also tried 3 varieties of the new bind function format, both also don't seem to ever fire the routing function.

    Read the article

  • angular-ui-router : breadcrumps ok but view ko

    - by anakin59490
    this is my app.router.js : agentRouter.config([ '$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { var root = { name: 'root', abstract: true, url: '', title: 'home', views: { 'header': { templateUrl: 'views/headers/header.app.html', controller: 'HeaderCtrl' }, 'body': { templateUrl: "views/root.html" }, 'footer': { templateUrl: 'views/footers/footer.app.html' } } }; var agent = { name: 'root.agent', url: '/agent', title: 'agent', views: { 'root.sidebar': { templateUrl: "views/main.sidebar.html" }, 'root.container': { templateUrl: "views/partials/agent/list.container.html" } } }; var detail = { name: 'root.agent.detail', url: '/detail/:id', title: 'agentDetail', // use for breadcrumb views: { 'root.sidebar': { templateUrl: "views/main.sidebar.html" }, 'root.container': { templateUrl: "views/partials/agent/list.chantier.html" } } }; /.../ $stateProvider.state(root); $stateProvider.state(agent); $stateProvider.state(detail); } ]); and this is my root.html : <!--Breadcrumb content--> <ul class="row breadcrumb"> <i class="glyphicon glyphicon-home" style=""></i> <li ng-repeat="state in $state.$current.path"> <a ng-href="#{{state.url.format($stateParams)}}"><span ng-bind="state.title"></span></a> <span ng-hide="$last" class=""></span> </li> </ul> <!--Sidebar content--> <div ui-view="root.sidebar">default root.sidebar</div> <!--Container content--> <div style="background-color: #f9f9f9" ui-view="root.container">default root.container</div> I can access to my "agent" page (a list of person) and my breadcrumb is right : home / agent but when i click on an item of the list i got always the same page but my breadcrumb is right : home / agent / agentDetail but in app.router.js if change detail like this : var detail = { name: 'root.detail', // référence initiale + detail (fils) url: '/agent/detail/:id', // réference utilisée dans les fichiers HTML, attention c'est la suite de l'url précédente!!! title: 'agentDetail', // référence utilisée pour le breadcump views: { 'root.sidebar': { templateUrl: "views/main.sidebar.html" }, 'root.container': { templateUrl: "views/partials/agent/list.chantier.html" } } }; i got the right page (list.chantier.xml) but the breadcrumb is false : home / agentDetail instead of home / agent / agentDetail I would like to got the right breadcrumb (home / agent / agentDetail) with the right page (list.chantier.html) when i click on an item of the agent list page (list.container.html) Thank you in advance for your help

    Read the article

  • Angular function constructor in Controller

    - by BigHeadCreations
    In normal JS I can do this: function Droppable() { this.relevant = true; this.uuid = generateUUID(); }; var generateUUID = function() { return '12345'; } console.log(new Droppable); // returns Droppable {relevant: true, uuid: "12345"} But in Angular I have this: angular.module('myApp').controller('MyCtrl', ['$scope', function($scope) { function Droppable() { this.relevant = true; this.uuid = generateUUID(); } var generateUUID = function() { return '12345'; } // initalize droppable areas $scope.region1 = [new Droppable]; $scope.region2 = [new Droppable]; $scope.region3 = [new Droppable]; }]); I am trying to make 3 droppable areas all with a UUID. But when I do this I get 'undefined is not a function' referring to the line this.uuid = generateUUID(); in function Droppable() {...} Why is that?

    Read the article

  • Angular JS pagination after data loaded

    - by Federico Bucchi
    do you have any example of Angular JS elements pagination loaded from I file? I found this example: http://jsfiddle.net/SAWsA/11/ Now, instead of having this: $scope.items = [ {"id":"1","name":"name 1","description":"description 1","field3":"field3 1","field4":"field4 1","field5 ":"field5 1"}, {"id":"2","name":"name 2","description":"description 1","field3":"field3 2","field4":"field4 2","field5 ":"field5 2"}, {"id":"3","name":"name 3","description":"description 1","field3":"field3 3","field4":"field4 3","field5 ":"field5 3"}, {"id":"4","name":"name 4","description":"description 1","field3":"field3 4","field4":"field4 4","field5 ":"field5 4"}, {"id":"5","name":"name 5","description":"description 1","field3":"field3 5","field4":"field4 5","field5 ":"field5 5"}, {"id":"6","name":"name 6","description":"description 1","field3":"field3 6","field4":"field4 6","field5 ":"field5 6"}, {"id":"7","name":"name 7","description":"description 1","field3":"field3 7","field4":"field4 7","field5 ":"field5 7"}, {"id":"8","name":"name 8","description":"description 1","field3":"field3 8","field4":"field4 8","field5 ":"field5 8"}, {"id":"9","name":"name 9","description":"description 1","field3":"field3 9","field4":"field4 9","field5 ":"field5 9"}, {"id":"10","name":"name 10","description":"description 1","field3":"field3 10","field4":"field4 10","field5 ":"field5 10"}, {"id":"11","name":"name 11","description":"description 1","field3":"field3 11","field4":"field4 11","field5 ":"field5 11"}, {"id":"12","name":"name 12","description":"description 1","field3":"field3 12","field4":"field4 12","field5 ":"field5 12"}, {"id":"13","name":"name 13","description":"description 1","field3":"field3 13","field4":"field4 13","field5 ":"field5 13"}, {"id":"14","name":"name 14","description":"description 1","field3":"field3 14","field4":"field4 14","field5 ":"field5 14"}, {"id":"15","name":"name 15","description":"description 1","field3":"field3 15","field4":"field4 15","field5 ":"field5 15"}, {"id":"16","name":"name 16","description":"description 1","field3":"field3 16","field4":"field4 16","field5 ":"field5 16"}, {"id":"17","name":"name 17","description":"description 1","field3":"field3 17","field4":"field4 17","field5 ":"field5 17"}, {"id":"18","name":"name 18","description":"description 1","field3":"field3 18","field4":"field4 18","field5 ":"field5 18"}, {"id":"19","name":"name 19","description":"description 1","field3":"field3 19","field4":"field4 19","field5 ":"field5 19"}, {"id":"20","name":"name 20","description":"description 1","field3":"field3 20","field4":"field4 20","field5 ":"field5 20"} ]; I have to use something generated by: $http.get('/json/mocks/apps/applications.json') .then(function (result) { $scope.items = result.data.applications; }); How would you create the pagination waiting for the data loaded from $http.get?

    Read the article

  • Getting Result of $q's Resolution or Rejection

    - by Kevin Meredith
    I'm looking at a $q example from Mastering Web Application Development with Angular. For this code, how can I retrieve the String result of pizzaOrderFulfillment.resolve(...) or pizzaOrderFulfillment.reject? var myApp = angular.module('myApp',[]); myApp.controller("MyCtrl", function ($scope, $q) { var Person = function(name) { this.eat = function(food) { return name + " is eating " + food; }; this.beHungry = function(reason) { return name + " is hungry because" + reason; }; }; // success var pizzaOrderFulfillment = $q.defer(); var pizzaDelivered = pizzaOrderFulfillment.promise; var man = new Person("man"); pizzaDelivered.then(man.eat, man.beHungry); pizzaOrderFulfillment.resolve("chicken"); // TODO: var successResult = "man is eating chicken" });

    Read the article

  • How to use use external js in typescript

    - by Krishan
    I Generate the Angular JS code through the Typescript code. In one situation, I need to add external JS file to my typescript file and need to access the classes in the js file. I add that js file like this. /// <amd-dependency path="../../vendor/tweenMax.js" /> But still the typescript file can not identify the objects of that javascript file. If someone knows the suitable way, please add your answer. (I'm using min. js file)

    Read the article

  • Yeoman 'grunt test' fails on clean project with 'port already in use'

    - by XMLilley
    With: Mac OS 10.8.4 Node 0.10.12 npm 1.3.1 grunt-cli 0.1.9 yo 1.0.0-rc.1 bower 0.9.2 [email protected] I encounter the following error with a clean yo angular project, followed by grunt server then grunt test: Running "connect:test" (connect) task Fatal error: Port 9000 is already in use by another process. I'm new to Yeoman and am stumped. I've deleted my original project and created a new one in a fresh folder just to make sure I wasn't overlooking any invisible configs. I restarted the machine to make sure I wasn't running any temporary server processes I had forgotten about. After all attempts, the basic server starts fine, attaches to Chrome, and the watcher updates the browser on any changes. (Notably, the server is running on 9000, which seems odd for the test-runner to also be trying to use 9000.) But I get that same error on attempting to start the test runner. Is this something I can fix, or an issue I should report to the Yeoman team? Thanks.

    Read the article

  • making a password-only auth with bcrypt and mongoose

    - by user3081123
    I want to create service that let you login only with password. You type a password and if this password exists - you are logged in and if it's not - username is generated and password is encrypted. I'm having some misunderstandings and hope someone would help me to show where I'm mistaken. I guess, it would look somewhat like this in agularjs First we receive a password in login controller. $scope.signup = function() { var user = { password: $scope.password, }; $http.post('/auth/signup', user); }; Send it via http.post and get in in our node server file. We are provided with a compare password bcrypt function userSchema.methods.comparePassword = function(candidatePassword, cb) { bcrypt.compare(candidatePassword, this.password, function(err, isMatch) { if (err) return cb(err); cb(null, isMatch); }); }; So right now we are creating function to catch our http request app.post('/auth/signup', function(req, res, next) { Inside we use a compair password function to realize if such password exists or not yet. So we have to encrypt a password with bcrypt to make a comparison First we hash it same way as in .pre var encPass; bcrypt.genSalt(10, function(err, salt) { if (err) return next(err); bcrypt.hash(req.body.password, salt, function(err, hash) { if (err) return next(err); encPass=hash; )}; )}; We have encrypted password stored in encPass so now we follow to finding a user in database with this password User.findOne({ password: encPass }, function(err, user) { if (user) { //user exists, it means we should pass an ID of this user to a controller to display it in a view. I don't know how. res.send({user.name}) //like this? How should controller receive this? With $http.post? } else { and now if user doesn't exist - we should create it with user ID generated by my function var nUser = new User({ name: generId(), password: req.body.password }); nUser.save(function(err) { if (err) return next(err); )}; )}; )}; Am I doing anything right? I'm pretty new to js and angular. If so - how do I throw a username back at controller? If someone is interested - this service exists for 100+ symbol passphrases so possibility of entering same passphrase as someone else is miserable. And yeah, If someone logged in under 123 password - the other guy will log in as same user if he entered 123 password, but hey, you are warned to make a big passphrase. So I'm confident about the idea and I only need a help with understanding and realization.

    Read the article

  • Unit-testing a directive with isolated scope and bidirectional value

    - by unludo
    I want to unit test a directive which looks like this: angular.module('myApp', []) .directive('myTest', function () { return { restrict: 'E', scope: { message: '='}, replace: true, template: '<div ng-if="message"><p>{{message}}</p></div>', link: function (scope, element, attrs) { } }; }); Here is my failing test: describe('myTest directive:', function () { var scope, compile, validHTML; validHTML = '<my-test message="message"></my-test>'; beforeEach(module('myApp')); beforeEach(inject(function($compile, $rootScope){ scope = $rootScope.$new(); compile = $compile; })); function create() { var elem, compiledElem; elem = angular.element(validHTML); compiledElem = compile(elem)(scope); scope.$digest(); return compiledElem; } it('should have a scope on root element', function () { scope.message = 'not empty'; var el = create(); console.log(el.text()); expect(el.text()).toBeDefined(); expect(el.text()).not.toBe(''); }); }); Can you spot why it's failing? The corresponding jsFiddle Thanks :)

    Read the article

  • Angular.js: value() not injected in config()

    - by Nik
    I am having trouble getting the value() injected into the app.config(). Here's the code (coffeescript) window.app = angular.module("app", []) app.value("template_path", "assets/angular/templates/users") app.config(["$routeProvider","template_path" ($routeProvider, template_path) -> console.log template_path it is throwing an "Unknown provider: template_path from app" error Could it be that the config() method cannot be injected with value() set values? I am using 1.0.2 Thank you!

    Read the article

  • How can I show a count of rows from an ng-repeat?

    - by Anne
    I have a table on my web page that is populated with data like this: <tr data-ng-repeat="row in grid.data | filter:isQuestionInRange"> <td>{{ row.problemId }}</td> </tr> Is there a way that I can put a count of the rows displayed in the table footer. Note that I want to be able to show the rows after that have been filtered not just the row count from the grid.data array.

    Read the article

  • How to hide an element after $compile?

    - by Miron
    How to hide directive generated html after inserting it to body? Directive has "replace" set to trueThere is a directive: .directive('location', function () { return { restrict : 'A', scope : {}, replace : true, templateUrl: 'common/components/location/location.html', link : function (scope, element, attr) {……} } }); So it is used in another directive: var scope = $rootScope.$new(true); var directive = $compile('<div location></div>')(scope); $document.find('body').append(directive); directive.hide(); - not working How to hide directive generated html after inserting it to body? Directive has "replace" set to true

    Read the article

  • Loading a view routed by a URL parameter (e.g., /users/:id) in MEAN stack

    - by Matt Rowles
    I am having difficulties with trying to load a user by their id, for some reason my http.get call isn't hitting my controller. I get the following error in the browser console: TypeError: undefined is not a function at new <anonymous> (http://localhost:9000/scripts/controllers/users.js:10:8) Update I've fixed my code up as per comments below, but now my code just enters an infinite loop in the angular users controllers (see code below). I am using the Angular Express Generator for reference Backend - nodejs, express, mongo routes.js: // not sure if this is required, but have used it before? app.param('username', users.show); app.route('/api/users/:username') .get(users.show); controller.js: // This never gets hit exports.show = function (req, res, next, username) { User.findOne({ username: username }) .exec(function (err, user) { req.user = user; res.json(req.user || null); }); }; Frontend - angular app.js: $routeProvider .when('/users/:username', { templateUrl: function( params ){ return 'users/view/' + params.username; }, controller: 'UsersCtrl' }) services/user.js: angular.module('app') .factory('User', function ($resource) { return $resource('/api/users/:username', { username: '@username' }, { update: { method: 'PUT', params: {} }, get: { method: 'GET', params: { username:'username' } } }); }); controllers/users.js: angular.module('app') .controller('UsersCtrl', ['$scope', '$http', '$routeParams', '$route', 'User', function ($scope, $http, $routeParams, $route, User) { // this returns the error above $http.get( '/api/users/' + $routeParams.username ) .success(function( user ) { $scope.user = user; }) .error(function( err) { console.log( err ); }); }]); If it helps, I'm using this setup

    Read the article

  • Third party library not working with angular js

    - by sarvesh
    I am using navgoco.js and angular js in an application and I have following html <div id="demo"> <ul > <li ng-repeat ... > <a href="#"> ... </a> ...... </li> </ul> </div> js code $j("#demo1").navgoco({accordion: false}); It is supposed to do some expand-collapse of menus. the problem is that navgoco events are not performing on clicking on anchor. It simply adds # to url. In the rendered html of anchor tag, anuglar is adding ng-binding that may be the problem. Please help.

    Read the article

  • Vew not updating after scope update

    - by bsparacino
    Here is a very simple example of what I am trying to do Athlete.save(athlete,function(result) { $scope.athlete = result.athlete; }); The issue is that the $scope.athlete variable does not update in my view. In order to get it to update I have to do this Athlete.save(athlete,function(result) { $scope.athlete.fname = result.athlete.fname; $scope.athlete.lname= result.athlete.lname; $scope.athlete.gender= result.athlete.gender; .... }); This gets annoying very quickly. With the first block of code it's as if angular does not know that my $scope.athlete variable has been updated. This function is triggered from an ng-click, not some jquery call, I am doing it the angular way as far as I know. here is a simpler case I made: http://plnkr.co/edit/lMCPbzqDOoa5K4GXGhCp

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >