Wrox Programmer Forums
|
BOOK: Professional AngularJS
This is the forum to discuss the Wrox book Professional AngularJS by Valeri Karpov, Diego Netto; ISBN: 978-1-118-83207-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional AngularJS section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 4th, 2016, 05:48 AM
pip pip is offline
Registered User
 
Join Date: Jan 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Scope Variables in watchlist controller not being created

Quote:
Originally Posted by dougal83 View Post
I figured it out... Yeoman automatically adds "controllerAs: 'watchlist'" to the route causing a conflict with the keyword. We wont be using the controllerAs alias so you can just comment it out like below(or just change either variable name):

PHP Code:
      .when('/watchlist/:listId', {
        
templateUrl'views/watchlist.html',
        
controller'WatchlistCtrl'//,
        //controllerAs: 'watchlist'
      
}) 
EDIT: app/scripts/app.js

Voila! Working code and no more head scratching.
Hi, I've had the same problem, but this solution above didn't fix it for me. I noticed that none of the scope variables created in the watchlist controller (watchlist.js) are being created in the scope. It appears only scope variables created in the main controller are appearing. I've been banging my head against the wall on this for days now. Please help
 
Old January 4th, 2016, 06:23 PM
Authorized User
Points: 130, Level: 2
Points: 130, Level: 2 Points: 130, Level: 2 Points: 130, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2015
Posts: 18
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Obviously would need to see your code.. but I'm tight on time. First off try and solve it yourself... I have posted a working example(variation using ui-bootstrap) https://github.com/dougal83/stock-dog

See how the code varies compared to relevant parts of your project. If you exhaust your search, post your project online (github?) along with any error messages, so someone else can replicate and see if they can see what is wrong allowing for free time.
 
Old March 28th, 2017, 06:12 PM
Registered User
 
Join Date: Mar 2017
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Red face

Thanks, this was hard for me to find out.

Moreover I had introduced another bug: I forgot to isolate the scope of the stkWatchlistPanel directive so $scope.watchlist got overwritten by it:

PHP Code:
  .directive('stkWatchlistPanel',
  function (
$location$modal$routeParamsWatchlistService) {
    return {
      
templateUrl'views/templates/watchlist-panel.html',
      
restrict'E',
      
scope: {},        // <<== isolate scope
      
link: function ($scope) {
        
// [2] initialize variables
        
$scope.watchlist = {}; 
Maybe this helps someone some day

Last edited by codekraft; March 28th, 2017 at 06:14 PM.. Reason: change [CODE] to [PHP] for better syntax highlighting





Similar Threads
Thread Thread Starter Forum Replies Last Post
Modal Popup Extender - not modal? jenbuh ASP.NET 3.5 Professionals 5 July 27th, 2009 07:04 PM
MsgBox not Modal? tknnguyen Visual Basic 2008 Professionals 3 February 18th, 2009 11:55 AM
Modal Window... babloo81 Javascript 2 February 21st, 2005 07:08 AM
modal window pablens Classic ASP Professional 3 December 28th, 2004 05:28 PM
Modal Forms aspadda Excel VBA 2 November 26th, 2003 11:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.