w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Spring scheduler tasks: read configuration on running time
I will use this approach: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/dynamic-language.html So I could have my configuration files, change it and automatically they will be catched.

Categories : Spring

What does $scope.$apply() do?
Simply put it: (Optionally) Processes an expression you pass to it as an argument. Calls $digest() on the $rootScope. I also wrote a blog entry about what $apply, $digest and $watch do and how they work together I hope that helps.

Categories : Javascript

Why should I make $scope.$apply()?
It is because $apply is a lazy worker and will do the job only there is enough stuff to refresh. You can't control when, unless you explicitly call $scope.$apply. Yes, there is a better way to do this : call safeApply. Because calling explicitly many $apply can cause conflicts. There is no official safeApply implementation, so can choose you poison : here : https://coderwall.com/p/ngisma or there : Prevent error $digest already in progress when calling $scope.$apply()

Categories : Javascript

Running $apply on $rootScope vs any other scope
Running $digest/$apply on any given scope will visit all other scopes using depth-first traversal: https://github.com/angular/angular.js/blob/3967f5f7d6c8aa7b41a5352b12f457e2fbaa251a/src/ng/rootScope.js#L550-L558 That means that the only difference is that the $digest will start at whatever $scope it was called on

Categories : Angularjs

AngularJS - Do I need $scope.$apply when using $http
With AngularJS version 1.1.x you will need to add Scope.$apply if triggering $http calls outside of the AngularJS $digest cycle. Detailed explanations here: http://stackoverflow.com/a/17271385/1418796

Categories : Ajax

AngularJs $scope.$apply not working as expected
Copied from my comment to make it clearer what the problem was: I managed to figure out the problem. When using their example I had a duplicate of ng-controller(Their example was nested within my other controller) and even though both were using the same controller it seems like it would only update anything that was within nested controller scope. When removing the duplicate ng-controller attribute it all works fine.

Categories : Angularjs

scope change in a directive not a apply in view
ng-include creates a new scope so scope.showDiv only affects the local scope. Depending on how you want to structure your application, you could try accessing scope.$parent.showDiv instead, but it is not really future proof as it will depend on the HTML nesting. A better solution would be to have the showDiv property stored inside an object in the parent scope. For example scope.ui = {}, this way, when you set scope.ui.showDiv = true in your directive, it will look up the parent scope automatically (using prototype inheritance), instead of adding the property to the local scope. Finally, another solution would be to refactor your code to make it less complex: I think using a ng-include just for adding one element is an overkill, you could put directly <a ng-support></a> insid

Categories : Angularjs

Passing function arguments to $scope.$apply?
Wrap stripeCallback into an anonymous function: var stripeCallback = function (status, response) { .... }; $scope.submit = function () { $scope.errorMessage = 'Processing...'; $scope.buttonDisabled = true; // can't use bindings for some reason var myForm = $('#paymentform'); Stripe.createToken(myForm, function (status, response) { $scope.$apply(function() { stripeCallback(status, response); }); }); };

Categories : Javascript

applying changes to a model in angular.js that was fetched by scope.$apply
When you want bi-directional binding between a directive and controller scope, you should use the scope property when defining the directive. var app = angular.module("app", []); app.controller("Ctrl", function ($scope) { $scope.project = { elements: [1, 2, 3] }; }); app.directive("customDirective", function () { return { restrict: "E", scope: { sortableModel: "=" }, link: function (scope, element, attrs) { // Access the controller's scope.project.elements here as scope.sortableModel console.log(scope.sortableModel); // Changes to scope.sortableModel will also affect the controller's scope.project.elements scope.sortableModel.push(4); } }; }); See a working fid

Categories : Javascript

In Angularjs, can I $apply / render a single scope at a time?
Whenever you call $scope.$apply() it also calls $apply() on all scopes that fall within that scope. If you want to call $apply() on a limited section of a page then that section needs to have it's own scope, which you can do by adding a controller to that section of the page. Then you can use that controller to update the scopes within that section of the page using $scope.apply() on your section controller. -- Edit -- See comments below for additional details about the differences between $apply and $digest. Also see: http://jimhoskins.com/2012/12/17/angularjs-and-apply.html https://groups.google.com/forum/#!topic/angular/SSj61VOBBSc

Categories : Performance

Angularjs async callback return undefined under $scope.$apply();
Wrap the outside service's deferred resolve in a $timeout block to let angular know when its resolved. This way when your controller runs then callback, it'll be in a $digest cycle. See this fiddle as a working proof of concept: http://jsfiddle.net/Zmetser/rkJKt/ // in controller authService.login().then(success, error); // service myapp.factory('authService', ['$q', '$timeout', function( $q, $timeout ) { var auth = {}, deferred; firebaseAuthClient = new FirebaseAuthClient(FIREBASEREF, afterAuth); function afterAuth( error, user ) { // Let angular know the deferred has been resolved. $timeout(function () { if (user) { deferred.resolve(user); } else if (error) { deferred.reject(error); } else {

Categories : Angularjs

Magento Setting Admin Configuration Values for Store View Scope via XML
You can use this : <stores> <your_store_code> <design> <email> <logo>value</logo> </email> </design> </your_store_code> </stores>

Categories : Magento

AngularJS: Can you get a 'digest in progress' error from multiple $scope.$apply() calls?
Javascript is single-threaded. Each call to $apply() runs synchronously. The only way to get that error is to call $apply() from within a function that has been called in the Angular context. I've had arrays of arrays of multiple large blocks of shown/hidden blocks with no problems. Javascript and Angular are pretty optimized.

Categories : Javascript

The "bag of tasks" concept in C#, enqueue,pause,cancel logical tasks
Yes, you can do that. First, you have a main thread, your application. There you have two workers, represented by threads. The first worker would be a producer and the second worker would be a consumer. When your application starts, you start the workers. Both of them operates on the concurrency collection, the bag. Producer searches for files and puts references to the bag and consumer takes references from the bag and starts a task per reference. When you want to signal pause, simply pause the producer. If you do that, consumer also stops working if there is nothing in the bag. If this is not a desired behaviour, you can simply define that pausing of the producer also clears the bag - backup your bag first and than clear it. This way all running tasks will finish their job and consumer

Categories : C#

SecurityException when enumerating V1 tasks and displaying tasks' info using a DataGrid
This is courtesy of dahall over at codeplex (Thanks a lot dahall) First, try putting brackets in around the scope of your first using statement. You can also do the same with the TaskService instance. You could do this by doing: List<TaskInfo> taskList = new List<TaskInfo>(); using (TaskService ts = new TaskService(REMOTE", "username", "domain", "password", osVer.Contains("2003"))) { EnumFolderTasks(ts.RootFolder, taskList); } DataContext = taskList; I am not sure why this happens only for the V1 calls, but this did solve my problem.

Categories : C#

angularjs: directive creates two child scope(not isolation scope)? and how to get scope of an element?[Solved by clear answer]
it's hard to figure out without any jsfiddle for the context. What is your link function? and what is your controller function? By the way, it is the normal behaviour as documentation says transclude:true creates also a new scope. Look at here : https://github.com/angular/angular.js/wiki/Understanding-Scopes The transcluded and the isolated scope (if any) are siblings -- the $parent property of each scope references the same parent scope. When a transcluded and an isolate scope both exist, isolate scope property $$nextSibling will reference the transcluded scope. So if you want to access the 2 siblings from one another, you have to use a 2-way binding with their parent

Categories : Angularjs

How do I connect between parent $scope, directive $scope and a modal $scope?
Like I said in the comment you can access the variables from the parent scope in the modal popups scope. HTML <div ng-app="app" id="app"> <div ng-controller="MainCtrl"> <label-select color="{{color}}"></label-select> <div class="flyout"> <ul> <li ng-click="setColor(color)" ng-repeat="color in colors">{{color}}</li> </ul> </div> </div> </div> JS var app = angular.module('app', []); app.controller('MainCtrl', function ($scope) { $scope.color = "#AAADDD"; $scope.colors = ["#AAA", "#BBB", "#CCC", "#DDD", "#EEE"]; $scope.setColor = function (color) { angular.element(".flyout").removeClass("show"); $scope.color = color;

Categories : Javascript

How to use jars from a Java Project in an Android project transitively over the included Android library?
I think you should be able to go to the properties of your Android library project, go to Java Build Path, switch to the tab Order and Export and select the java library so that it is exposed to the Android project that uses the Android library.

Categories : Java

EF Code First Configuration of shared Base Class --> Single Configuration File
Try it like below but I didnt test it .However if I were you, I wouldnt design Audit tables this way class AuditableModelBaseMap : EntityTypeConfiguration<AuditableModelBase> { public AuditableModelBaseMap () { this.HasRequired(amb => amb.CreatedByUserProfile).WithMany().HasForeignKey(amb => amb.CreatedByUserId).WillCascadeOnDelete(false); this.HasRequired(amb => amb.UpdatedByUserProfile).WithMany().HasForeignKey(amb => amb.UpdatedByUserId).WillCascadeOnDelete(false); } } THIS IS MY WAY OF Doing AUDITING public interface IEntity { int Id { get; set; } } public interface IAuditable : IEntity { string UpdatedBy { get; set; }

Categories : C#

static library builds in debug configuration but not in release configuration
For your project target Build Settings, look for "Search Paths->Header Search Path". Compare your Release and Debug settings here. Also look into the "Build Location" for the library project for Release and Debug.

Categories : IOS

Is there a way to obtain a Configuration object from a configuration file in the isolated storage?
Why can't you get the absolute path to the files in Isolated Storage? Take a look at the Can I get a path for a IsolatedStorage file and read it from external applications? post to find out how you can do this. If that doesn't work for you, take a look at the IsolatedStorageFile Class page at MSDN which features examples of manipulating files in IsolatedStorage.

Categories : Wpf

what is active solution configuration in vs 2012 configuration manager?
my understanding is it should use the QA web.config file. am i wrong? Actually you are wrong. web.QA.config will be used only when you publish your application but not while running it in Visual Studio where the standard web.config is always used.

Categories : Visual Studio 2010

R: Split-Apply-Combine... Apply Functions via Aggregate to Row-Bound Data Frames Subset by Class
You've tackled this problem in a way that makes it very hard to debug. I'd recommend switching things around so you can more easily check each step. (Using informative variable names also helps!) The code is unlikely to work as is, but it should be much easier to work iteratively, checking that each step has succeeded before continuing to the next. paths <- dir("C:/Data/", pattern = "\.csv$") # Read in CSV files as data frames raw <- lapply(paths, read.csv, str) # Extract needed rows filter_metrics <- c("MaxTemp", "AvgTemp", "MinTemp") filter_years <- 1970:2000 filtered <- lapply(raw, subset, !is.na(Value) & Year %in% filter_years & Element %in% filter_metrics) # Drop any empty data frames rows <- vapply(filtered, nrow, integer(1)) filtered <- filtered[r

Categories : R

Complex rolling scenario (CROSS APPLY and OUTER APPLY example)
I assume that you have a DimDate table with the following structure: CREATE TABLE DimDate ( DateKey INT PRIMARY KEY ); and DateKey column doesn't has gaps. Solution: DECLARE @NumDays INT = 3; WITH basic_cte AS ( SELECT x.DateKey, d.Name, Amount = ISNULL(f.Amount,0) FROM ( SELECT t.*, CONVERT(INT,CONVERT(CHAR(8),CONVERT(DATETIME,CONVERT(DATETIME,CONVERT(CHAR(8),t.LiveKey,112))+@NumDays),112)) AS EndLiveKey FROM #target t ) d CROSS APPLY ( SELECT dm.DateKey FROM DimDate dm WHERE dm.DateKey >= d.LiveKey AND dm.DateKey < d.EndLiveKey

Categories : SQL

Simplify apply, sapply apply expression on list of matrices
Not sure its any tidier apply(do.call(rbind, unlist(x, FALSE)), 2, max) [1] 383581.5 4635506.3 you can use the functional library not sure if base has these yet require(functional) dumcall <- Curry(do.call, what = 'rbind') doublebind <- Compose(dumcall, dumcall) apply(doublebind(x), 2, max) [1] 383581.5 4635506.3

Categories : R

Why ng-transclude's scope is not a child of its directive's scope - if the directive has an isolated scope?
Why ng-transclude's scope is not a child of its directive's scope if the directive has an isolated scope? ng-transclude designed to allow directives to work with arbitrary content, and isolated scopes are designed to allow directives to encapsulate their data. If ng-transclude didn't preserve scopes like that, any arbitrary content that you're transcluding would need to know the implementation details of your directive (i.e. it would need to know what's available on the isolated scope you created). If it's not a bug, how can a container directive pass data to it's content, if not by setting attributes like I tried. If the container directive and contained directives are coupled - i.e. you wrote both of them and need them to act together - then they should communicate via a shar

Categories : Angularjs

Difference between @list.tasks and @list.tasks.all in Rails
When you use @list.tasks it returns tasks belonging to this list and everything is as expected .all is deprecated method all which is just alias for calling find(:all). Thus, in @list.tasks.all you get @list.tasks.find(:all) which returns empty enumerable.

Categories : Ruby On Rails

log4j.properties configuration issues along with ant configuration
for ant i added: <path id="properties"> <dirset dir="${config.dir}"/> </path> where ${config.dir} is the path to the /src/config folder where the log4j.properties exists. Still working on getting eclipse to work, it shouldnt be too different with classpaths in eclipse. Thanks!

Categories : Java

AngularJS $scope.$watch properties of $scope.foo but send old values to server before change
The second parameter of $scope.$watch is a function which receives two parameters : the first one is the new value, the second one the old value. You can simply watch for the whole foo object, and set the third parameter of $scope.$watch to true in order to compare object for equality rather than for reference. Notice that this can be a pretty bad idea if your object is really large : $scope.$watch( 'foo', function (newFoo, oldFoo) { // send old $scope.foo to server with the // previous $scope.foo.bar and $scope.foo.baz }, true ); You can also watch separately foo.bar and foo.baz : var sendAndReplace = function (parameterName, oldParameter) { oldFoo = angular.copy($scope.foo); oldFoo[parameterName] = oldParameter; // send old oldFoo to s

Categories : Angularjs

Angularjs custom directive child scope access parent scope method?
The problem is that the slide directive from angular-ui-bootstrap has created an isolated scope, scope.$parent in the link function isn't the scope of carousel, therefore you can't access play and pause functions. In link function, you can get the carousel's scope by calling scope() on carousel element: var carouselScope = element.parent().parent().scope(); Then, use carouselScope to replace where you have put scope.$parent. http://plnkr.co/edit/1HCiqvTm1Fd9Rh0o8Mtw

Categories : Angularjs

How do you not override other angular directives when using isolate scope and still being able to call methods in the scope?
If you want allow any global directive - don't declare private scope. If you want allow only few directives, add links in scope declaration: scope: { onClick: "&", ngShow : "&" }, To your question in comments: Declare controller in directive and declare method in this controller. Then in directive template assign ng-click to this method. var def = { restrict: 'A', controller: function($scope){ $scope.callMe = function(){ console.log('foo'); } } } in template: <div ng-click="callMe()">content</div> This method will be accessible only inside your directive.

Categories : Angularjs

What dependency scope for Derby JDBC drivers in intergration scope (cayenne)
To ensure that the Derby driver is available during plugin execution (vs during your code compilation), you need to add it as a dependency of the plugin itself: <plugin> <groupId>org.apache.cayenne.plugins</groupId> <artifactId>maven-cayenne-plugin</artifactId> <version>3.2M1</version> <dependencies> <dependency> <groupId>org.apache.derby</groupId> <artifactId>derbyclient</artifactId> <version>10.10.1.1</version> </dependency> </dependencies> .... </plugin>

Categories : Maven

rails apply where if variable is not nil else apply all - nicer way
You can try something like this @country = Country @city = City if co.blank? @country = @country.where(:id => co) end if ci.blank? @city = @city.where(:id => ci) end @countries = @country.order(:name).all.map{|i| [i.name,i.id]} @cities = @city.order(:name).all.map{|i| [i.name,i.id]}

Categories : Ruby On Rails

ERROR [nucleusNamespace.] Invalid attempt to resolve component '' in scope global. It is defined in scope prototype
You might not be able to resolve lower scope component from higher scope object. If you are calling resolveComponent from global scope component will might not be able to resolve it. A component’s properties should always point to objects whose scope is equal to or greater than its own. Thus, global-scope component properties should only point to objects that also have global scope; session-scope component properties should only point to objects that have global or session scope; while request-scope component properties can point to objects of any scope, including request. Please read the ATG documentation below http://docs.oracle.com/cd/E35318_02/Platform.10-1-1/ATGPlatformProgGuide/html/s0205componentscopes01.html

Categories : Oracle

Angular JS propagate child scope variable changes to parent scope
This is due to how prototypal inheritance works. When you ask for $scope.x in the child controller, it checks to see if x is defined on its scope, and if not, looks for x in the parent scope. If you assign to the child scope's x property, it only modifies the child scope. An easy way to deal with this and get the sharing behavior is to use an object or an array. function ParentCtrl($scope) { $scope.model = {x: 5, y: 5}; } function ChildCtrl($scope) { $scope.update = function(x, y) { $scope.model.x = x; $scope.model.y = y; }; } Here, the changes will be visible in both scopes, because $scope.model will refer to the same object in both parent and child scopes. John Lindquist has a video on this.

Categories : Angularjs

Angular JS scope issue module not reading controller scope
After studying a little more about angular I realized that $$prevSibling goes up the scope chain of the elements so if you don't have an element to go to in the next scope level then you are going to receive back a null object because there is nothing there.

Categories : Javascript

AngularJS: Sharing scope behavior with sibling or descendant scope
You need a ChannelService.... .service('ChannelService', function () { return { changeChannel: function (scopeData, callback) { //change the channel if (angular.isFunction(callback)) { callback(); } } }; }); Usage: .controller('MyController', ['$scope', 'ChannelService', function ($scope, ChannelService) { $scope.dataForChangingChannel = {}; $scope.changeChannel = function () { //do UI stuff here ChannelService.changeChannel($scope.dataForChangingChannel, function () { //or UI stuff here, after the channel has been changed }); } }]);

Categories : Javascript

Why using directive behaves differently in global scope and in local scope?
The using-declaration is just that, a declaration. The using second::y; inside of main is similar to declaring a variable y in that scope which hides any other ys in global namespace scope. When you use using second::y; in global scope, you have not hidden any names, since both ys are in the same scope. Imagine your first example is like the following (please see the comments below for an explanation): namespace first { int x = 5; int y = 10; } int main () { using namespace first; // This makes first::y visible hereafter int y = 20; // This hides first::y (similar to using second::y) cout << x << endl; cout << y << endl; // Prints 20 } However, the second example is like: namespace first { int x = 5; int y = 10; } using namespace first; // Th

Categories : C++

How to access parent scope from within a custom directive *with own scope* in AngularJS?
scope: false transclude: false and you will have the same scope(with parent element) $scope.$watch(... There are a lot of ways how to access parent scope depending on this two options scope& transclude.

Categories : Angularjs

writing a Javascript function outside of scope to fire inside the scope
If you change you code to this: return { svg: function() { return svg; }, call: function(f) { f.call(this); } }; then it should correctly set the context within test to be d3m. Within that function you should then be able to access this.svg() to get the SVG object, but you will not be able to access the "private" lexically scoped variable svg directly, i.e.: var d3m = d3mill(); var test = function() { console.log(this.svg()); // OK console.log(svg); // not OK - undefined variable }; d3m.call(test); You could also just pass the svg parameter to f when it's called: return { svg: function() { return svg; }, call: function(f) { return f.call(this, svg); } // also added "return", just in case }; with usage: var d3m = d3mill(); var test = function(s

Categories : Javascript



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