w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Angular select within a ng-repeat directive: how can I access the children scopes?
You can define the selected object in the parent controller first. Objects you data-bind should always "have a dot" in them to avoid issues with prototypical inheritance, so you should bind to something like "selected.channel" rather than "selectedChannel" app.controller('midiCtrl', function ($scope, pluginDisplayedWindows) { $scope.plugins = pluginDisplayedWindows.pluginsDisplayed; // An object $scope.selected = {}; $scope.selected.channel = {}; $scope.selected.device = {}; $scope.channels = [ {ID: 'all', Title: 'All'}, {ID: '0', Title: '1'}, {ID: '1', Title: '2'}, {ID: '2', Title: '3'} ]; $scope.devices = [ {ID: '0', Title: 'Device A'}, {ID: '1', Title: 'Device B'}, {ID: '2', Title: 'Device C'}, {ID: '3', Title: 'Device D'}, ]; }); And update the HTM

Categories : Javascript

drag children & drop to parent and still access the children
It's because the event is bubbling up to the DOM tree. So you have to add next line at the beginning of your double click event handler : e.stopPropagation(); Then it will look like this in your code : function start_edit() { $('.account_line').dblclick(function (e) { e.stopPropagation(); var account_name = $(this).children('p').first().html() $('#account_edit').css({ display: 'block' }); $('#account_edit').children('#account_name_to_edit').html(account_name); }) } jQuery docs Description: Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.

Categories : Jquery

iOS: Parent/Children View Controllers and autorotation
For those two views (which you want to be available only in portrait mode): Open their View Controllers, and implement this method: - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ return UIInterfaceOrientationIsPortrait(toInterfaceOrientation); // don't rotate if it's not portrait. // if you don't want the upside down portrait mode to be available as well, return the expression from below // return toInterfaceOrientation == UIInterfaceOrientationPortrait; } This one is actually deprecated, so you also may want to use this: - (BOOL) shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; // if you want it to be also in upside down portrait mode, return the expres

Categories : IOS

use of $inject in angular js in controllers?
That is one approach to support Dependency Injection after your code is minified (if you choose to minify). When you declare a controller, the function takes parameters: function ($scope, notify) When you minify the code, your function will look like this: function (a, b) Since AngularJS uses the function parameter names to infer DI, your code will break because AngularJS doesn't know about a or b. To solve this problem, they provided additional ways to declare controllers (or other services/factories/etc) for that matter: 1) For controllers, use the $inject method - here you pass an array of literals that map to the parameters of your controller function. So, if you provide ['$scope', 'notify'] then the value of the first parameter to your function will be the a scope object

Categories : Angularjs

Asynchronous resources in Angular - how to use them between controllers?
I think you're looking for the resolve property of $routeProvider , as explained here: Delaying AngularJS route change until model loaded to prevent flicker Basically if you use a promise of the loaded resource in the second controller, it won't be instantiated until the request has finished and your data is ready.

Categories : Javascript

Testing Angular Directives with their own controllers
The way you'll end up accessing the controller in this case is by using the function the controller is placing in its scope from the HTML snippets that will form your test inputs. Note: The use of a jasmine spy may be overkill here, and I didn't take the time to look up the right methods for matching the arguments to $location.path() and/or $location.search(), but this should be enough to help you find the hook into a place for observation that you're looking for. 'use strict'; describe('Directive: Search', function() { var element, $location; // Load your directive module with $location replaced by a test mock. beforeEach( function() { module('myapp.directives'), function() { $provide.decorator('$location', function($delegate) { $delega

Categories : Angularjs

Controllers not talking to each other via service in Angular JS
I just remembered I already answered this here: How to share data between controllers in angularjs var app = angular.module('myApp', []); app.factory('myService', function() { var myService = { foo: 'bar' }; return myService; }); app.controller('myCtrl1', function(myService) { console.log(myService.foo); myService.foo = 'not bar anymore!'; }); app.controller('myCtrl2', function(myService) { console.log(myService.foo); }); The only thing you need to do is then set your $scope.cartModel = cartModel and then you could do things like ng-model="cartModel.someProp" and any change there is updating that property in your service and thus updating it to any $scope.cartModel that is referencing the service object.

Categories : Angularjs

Angular Convention for declaring controllers
Personally I do the following (reasons after): angular.module('myApp', []); angular.module('myApp').controller('myController', ['$dependency', 'anotherDependency', function($dependency, anotherDependency) { ... } ]); Reasons: I try and avoid the global scope Redundantly declaring dependencies with string equivalents allows you to safely minify your code It's consistent, clean and the whole story is there. Eg. with app.something you don't know what app is, with `angular.module('myApp').something' it's pretty obvious what that is. Edit: Just remembered a cool video I saw on this very topic a while ago - http://www.egghead.io/video/tTihyXaz4Bo. If you haven't checked out John's site, I highly recommend it. I was so impressed with his videos I donated, and you should t

Categories : Angularjs

Testing angular services with controllers
Solution that I've found seems to be very easy and nice: beforeEach(function () { inject(function ($rootScope) { scope = $rootScope.$new(); scope.$apply(function () { scope.value = true; }); $name.bind(scope, 'value'); scope.$apply(function () { scope.value = false; }); }); }); beforeEach(function () { value = $name.get('value'); }); it('should have $scope value', function () { expect(value).toBeFalsy(); });

Categories : Javascript

Angular service not passing between controllers
The problem is your TableRowCtrl saves the result of a function in its scope variable. When the service itself changes, the value in the scope does not because at that point, it's a simple property. You can either expose your service directly in the scope or wrap $scope.items in a function instead: function TableRowCtrl($scope, $http, sharedProperties) { $scope.items = function() { return sharedProperties.getProperty(); }; } // And in your view {{ items() }} Or function TableRowCtrl($scope, $http, sharedProperties) { $scope.shared = sharedProperties; } // And in your view {{ shared.getProperties() }} Edit: Simple plunkr here Edit #2: If the problem is a binding that isn't updated because of an asynchronous process, you can use $scope.$apply: $http.get('data/customers.js

Categories : Javascript

Angular.js UI-Router Children Scope
You will either have to: Add an additional abstract state at the top level that has a template of '<ui-view/> and also a controller with all the scope items you need. So you'd essentially be moving the important shared scope items be a part of this top level state instead of networks.details. Then set networks.details.show to populate this new state's view, e.g. "@newstate". Use a shared service to talk and maintain 'state' between the two state controllers. This may be the cleaner solution. Inject a service (e.g. "NetworksDetailsShowState") into both controllers and proxy the service's properties onto scope properties in both controllers and then change the service at will.

Categories : Javascript

Independent scopes for similar controllers in Angular
You can see a modified plnkr that works as you described here. Personally, I would restructure the architecture of the app and rethink the styleFactory implementation. Some points for thought: data = {"style":"color:"+color} replaces the whole data object, thus $scope.data = styleFactory.getData() works only for the last controllerA as the reference is lost for all others. Try creating a parent controller that will be on top of controllerA and controllerB. Try solving this problem using directives.

Categories : Angularjs

How does the scope reach between multiple controllers in angular?
ngController directive creates a new scope, which inherits from the parent scope. Your inner ngController declaration creates a new scope, where you can access the members of parent scope but any modification gets applied to current scope (true for string, int, boolean types), so $scope.age = true; //Creates a new property on the current scope. You should use the . notation or object if you need to handle this scenario. So age should be a object like $scope.age={overage:true}; and the corresponding binding gets affected like <div class="age red" ng-if="!(age.overage)"> whereever age is used. Please go through this https://github.com/angular/angular.js/wiki/Understanding-Scopes

Categories : Javascript

What's the idiomatic way to store a value for multiple controllers to use in Angular.js?
I would suggest storing the values in a service and injecting that service anywhere that you need the value. At config time, you can set the value to undefined and then you can fill it in whenever the value is available. This also allows you to use $watch to determine when the value is set. I'd also take a look at the HTTP Auth Interceptor Module for AngularJS. Here's a rough example that illustrates this concept. <div ng-app="exampleApp"> <div ng-controller="controller1"> {{ sharedData.someData }} </div> <div ng-controller="controller2"> <button ng-click="sharedData.someData='otherData'">Set Data</button> </div> </div> angular.module('exampleApp', []).controller('controller1', function(sharedData,

Categories : Angularjs

Testing Angular Controllers: Controller Not Defined
Same way you did the last one describe('evCalcApp controllers', function(){ beforeEach(module('evCalcApp.controllers')); var scope, ctrl, ctrl2; beforeEach(inject(function($controller, $rootScope) { scope = $rootScope.$new(); scope2 = $rootScope.$new(); ctrl = $controller('MyMileageCalcController', {$scope: scope}); ctrl2 = $controller('MyCtrl2', {$scope: scope2}); }));

Categories : Javascript

Angular Controllers and Services - Success and Error callbacks
I recently wrote a handful of caching services, and I couldn't decide between using deferreds or callbacks. I ended up using the deferreds route, and I love it. Having written the same thing twice, I can definitely say that for the people using your service, the changes are only slight. In the callbacks, they pass a callback for the continuation. In the deferreds, they daisy-chain a .then and pass it an anonymous function for the continuation. Very similar. Since Angular has the ability give special consideration to deferreds, I would recommend using the deferreds. If you set a scope variable to a deferred, Angular is smart enough to wait until that deferred.promise is resolved. Once it is resolved, Angular will then bind to the variable. It is pretty awesome. I would recommend emb

Categories : Javascript

Understanding why my angular controllers aren't updating on model changes
First of all, I think $scope.activeDay = Calendar.activeDay(); should be $scope.activeDay = Calendar.activeDay; Now, let's get to your problem. At the beginning, Calendar.activeDay and $scope.activeDay are referring to the same this.day; however, when you do Calendar.activeDay = this.day again, Calendar.activeDay is changed to point to the new day, but $scope.activeDay is still referring to the previous this.day, this is the reason why DayCtrl isn't picking up the changes. It looks like you're using Calendar object to communicate between scopes, so one way to solve the problem is to attach Calendar object to each scope, and use Calendar.activeDay in ngModel. Another way is to use $scope.$watch in DayCtrl: $scope.$watch(function() { return Calendar.activeDay; }, function(newDay) {

Categories : Angularjs

How do I test controllers with Angular Translate initialized in App Config?
Avoid initialize application level module, put your controllers in myApp.controllers and test this module instead. "We recommend that you break your application to multiple modules. (...) The reason for this breakup is that in your tests, it is often necessary to ignore the initialization code, which tends to be difficult to test." http://docs.angularjs.org/guide/module

Categories : Angularjs

Representing Angular Scopes and Controllers on Sequence Diagrams
The scope is just the "glue" between the view and the controller, the medium between the two of them. So, in my opinion, it shouldn't be represented in a diagram. I think you should describe how the view communicates with the controller in terms of the controller methods as if there wasn't nothing between them.

Categories : Angularjs

Angular: share asynchronous service data between controllers
you are returning a promise in the factory's return object and not the actual object itself. so in you scope you should actually wait for the promise to mend a concrete object then assign it to $scope.message example: function ControllerA($scope, myService) { myService.getMessage().then(function(obj){ $scope.message=obj }); } i changed your fiddle into something that might be your answer, see this fiddle

Categories : Javascript

Angular: Update service and share data between controllers
You can use $broadcast to broadcast an event to the rootScope and use $on to define listener to listen to this specific event. function ControllerA($scope, myService, $rootScope) { $scope.message = myService.getMessages(); $scope.updateMessage = function () { $scope.message = 'Hello Max'; $rootScope.$broadcast("HelloEvent", { msg: $scope.message }); }; } function ControllerB($scope, myService, $rootScope) { $scope.message = myService.getMessages(); $rootScope.$on("HelloEvent", function (event, message) { $scope.message = message.msg; }); } Updated: I got the above solution just before you updated your question. If you don't want to use $broadcast or $on, you can share the object via $rootScope like this function Co

Categories : Javascript

Access to inherited children's variables of abstract class from another children of same abstract class
Your code works for me! I do not get a fatal error. The only thing I get is a notice because of the typo inside $this->variable in the child2 class. The original variable is incorrectly spelled "varialbe", but used consistently. Fixing the typo lets the code run completely error-free. So you fail to demonstrate the problem. Update your question if you find why the issue isn't included in your code. It must be somewhere else. And make sure you actually run your code before using it as an example, and that it has the problem you describe.

Categories : PHP

angular - controllers .then function called after directive so no data avail async call
Try using the success and error methods of the returned $http object if you're just trying to set a value. These methods are specific to the objects returned by $http. $http.get('data/data.json') .success(function(data, status, headers, config){ $scope.result = data; }) .error(function(data, status, headers, config){ console.log(data); )}; Any errors that you're getting could also be helpful. Also you probably don't want to couple your directive so tightly with your controller by referencing $scope.result. You may want to just pass in the data to render as an attribute, in which case egghead.io has some great tutorials on the subject (directive isolate scope).

Categories : Javascript

How to access Android XML children
it's imposible, because your definition is wrong, you can't use and item in that way, and defined other kind of resources like state or coordinates, I suggest you use a dimension resource, like: <dimen name="state_1_x">320px</dimen> you can change the "px" for other king of dimension, like dp, sp, or other. The items usually are used for integer or string arrays.

Categories : Android

How do I access a controllers scope after a transclusion?
You can use $$prevSibling to reference from the transcluded scope to the isolated scope created by the directive: <button data-ng-click="$$prevSibling.openDirective()">{{hello}} Open</button>

Categories : Angularjs

How to access properties from other view controllers
You've got your videoPlayer property defined in your viewController1.m, but you import viewController1.h. Move videoPlayer to viewController1.h. DO NOT import viewController1.m.

Categories : Objective C

Restrict webpage access with controllers
I think your best bet is just putting conditionals directly into your view, and also manually checking for permission on your controller: <td> <% if (User.IsInRole("Administrators") || User.Identity.Name == item.DomainAC) { %> <%: Html.ActionLink("Edit", "Edit", new { id=item.Id }) %> | <%: Html.ActionLink("Details", "Details", new { id=item.Id }) %> | <%: Html.ActionLink("Delete", "Delete", new { id=item.Id }) %> <% } %> </td> public ActionResult Edit(int id) { var user = GetUserById(id); if (!User.IsInRole("Administrators") && User.Identity.Name != user.DomainAC) { // unauthorized } // authorized - continue }

Categories : C#

Cannot access children's attributes in BeautifulSoup
Figured it out: It had to do with using the function in find_all() to eliminate the header row. I replaced the find_all line with rows = table.find_all("tr")[1:] because the header is always the first line, and it works.

Categories : Python

EmberJS - Access application controller from other controllers
Application Controller: App.ApplicationController = Ember.ObjectController.extend({ findPersonById: function(id) { ..... .... } }); Below is the way to access application controller function inside comments controller. Comments Controller App.CommentsController = Ember.ArrayController.extend({ needs: ["application"], getComments: function() { var person = this.get("controllers.application").findPersonById(id); .... .... } });

Categories : Ember Js

How to access children component of an enyo kind?
In answer to your question, yes, you can access any of the children of RobustList within the onSetupItem by using this.$. if it's a List. Check the documentation here: https://github.com/enyojs/enyo/wiki/Lists . Because of its flyweight pattern there's only one active set of controls within the List so you can refer to them directly by name. You wouldn't want to use this.$. to access the items in a Repeater because there are many copies of the components (one for each row). Use the passed in reference (e.g. var item = inEvent.item;) to access the items within the row template. I also notice you use 'fit: true' on a couple components in the list. You can only have one fit: true component in a FittableColumn/FittableRow. Neither of those is actually in a fittable so it won't probably

Categories : Javascript

In JavaScript, How can I access properties of children nodes?
You're looking for Element.children children returns a collection of child elements of the given element. In your example HTML: var b = document.querySelectorAll('a')[0]; alert(b.children[0].src); //First child's source: myimage.jpg (fiddle)

Categories : Javascript

Access children member of base list
If your element types are polymorphic, then yes. The only catch is that you need to store pointers to those polymorphic objects, because containers own their elements and if you were to try to add a Base into your list, it would be copied and sliced, losing all the context of its more derived nature. If it's an abstract class (as it should be), then the code won't even compile. I advise against raw pointers, so this is what we get: #include <list> #include <memory> #include <iostream> struct Base { virtual ~Base() {} virtual void foo() = 0; }; struct Derived1 : Base { void foo() { std::cout << "Lol! "; } }; struct Derived2 : Base { void foo() { std::cout << "Haha! "; } }; int main() { typedef std::list<std::unique_ptr<Base>> l

Categories : C++

Access jQuery node's children and its values using PHP to enter into db
have you tried using serialize to get the values of the input fields? you should be able to do something like $('tr:selected').serialize() It'd be easier to help if you had some kind of jsfiddle as an example of your problem.

Categories : PHP

Tree with Multiple Children - Linear Time Access Complexity
Instead of just having each node keep a regular list, have it either keep a sorted list(log n lookup) or a hashmap(constant time lookup). In this case sorting is probably the best so you can easily iterate over the elements and save space.

Categories : Algorithm

How to correctly access a parent controllers data (model) in nested resources?
1. Navigating to items/1/subitems throws an error: Your model is just a javascript object so there isn't a method get to fetch the data. You can access the subitems by just executing item.subitems. Also the argument of controllerFor() should be lower case. For instance: this.controllerFor('application') 2. Why do i have define the root data in a controller not route? You can set the model from the route in the setupController method. App.ApplicationRoute = Ember.Route.extend({ setupController: function(controller) { controller.set('model', { ... }); } }); http://jsfiddle.net/Y9kZP/

Categories : Ember Js

Query children and its children until there are no children simplified
I prefer to maintain a string property that represents a place in the hierarchy. For example, if the value was "/99/42" then you know the item belongs to parent 42 which belongs to 99. The reason this is nice is because then you can flatten out the whole collection of Foos and just query that field for those beginning with "/99" and you'll get the entire branch of the hierarchy. So your class would look like this: public class Foo { public int Id { get; set; } public string Name { get; set; } public string Path { get; set; } //eg: /99/42 } Hope that helps.

Categories : C#

JSON.parse returns children objects with null value, children values not being parsed
there are various js libraries predefined for parsing json and to get children values . What i usually do to parse json is use http://developer.yahoo.com/yui/json/ YUI library.

Categories : Javascript

Can I use jquery children() to select children of a child element?
So you only want the very first descendants to much from el that are either TRs, LIs, or OPTIONs I'm now assuming. I'm not sure where browser variation stands on the tablebody thing so I would probably play it safe with this: $('> li, > option, > tr, > tbody > tr', el);

Categories : Javascript

Cakephp best way to store count of children's children
According to your question, try the following code: function test(){ $this->loadModel('Student'); $joins = array( array( 'table' => 'courses', 'alias' => 'Course', 'type' => 'LEFT', 'conditions' => array('Course.id = Student.course_id') ), array( 'table' => 'schools', 'alias' => 'School', 'type' => 'LEFT', 'conditions' => array('School.id = Course.school_id') ), ); $school_wise_student_count = $this->Student->find('all', array('fields'=>array('count(Student.id) as total_student','School.name as school_name'), 'joins'=>$joins, 'group'=>arr

Categories : PHP

Rails One Parent, Two Children, Access Other Child's Attributes Through Parent
Couldn't you just do something with a where or join statement? messages = Message.joins(:subscriptions).where("messages.days_since > subscriptions.days_after") messages.each do |message| message.deliver end

Categories : Ruby On Rails



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.