How to make a namespace alias available only to a class

Namespace alias in the class definition is illegal, as specified by the language specification. Its allowed in only in namespace scope or function scope. You can make an alias at the namespace scope. But this will create a permanent alias which can be used from other files as well. However, the solution is simple: you … Read more

Are JavaScript variables declared in the body of an if statement scoped to the body?

1) Variables are visible for the whole function scope. Therefore, you should only declare them once. 2) You should not declare the variable twice in your example. I’d recommend declaring the variable at the top of the function, then just setting the value later: function actionPane(state) { var structure; if(state === “ed”) { structure = … Read more

In header files, what is the difference between a static global variable and a static data member?

Excuse me when I answer your questions out-of-order, it makes it easier to understand this way. When static variable is declared in a header file is its scope limited to .h file or across all units. There is no such thing as a “header file scope”. The header file gets included into source files. The … Read more

Where to put user defined functions in Angular JS?

One way is to create a service with the functions you want to share across multiple controllers. See this post for more info. After you do so you can inject the service you created into any controller and access the say() function with code something like this: function TestCtrl($scope, myService){ $scope.say = myService.say; } Where … Read more

What does this “(function(){});”, a function inside brackets, mean in javascript? [duplicate]

You’re immediately calling an anonymus function with a specific parameter. An example: (function(name){ alert(name); })(‘peter’) This alerts “peter“. In the case of jQuery you might pass jQuery as a parameter and use $ in your function. So you can still use jQuery in noConflict-mode but use the handy $: jQuery.noConflict() (function($){ var obj = $(‘<div/>’, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)