Questions tagged [using-directives]

The `using` directive, available in several languages including C# and C++, introduces members of a namespace into the current identifier search scope.

The C++ using directive allows the names in a namespace to be used without the namespace-name as an explicit qualifier. Of course, the complete, qualified name can still be used to improve readability.

// C++ Example:
using std::cout

The C# using directive is used to qualify namespaces and create namespace or type aliases. The scope of a using directive is limited to the file in which it appears.

// C# Example:
using System.Text;
using Project = PC.MyCompany.Project;

Creating an alias for a namespace or a type in C# is called a "using alias directive", and is illustrated in the code sample below:

namespace PC
{
    // Define an alias for the nested namespace. 
    using Project = PC.MyCompany.Project;
    class A
    {
        void M()
        {
            // Use the alias
            Project.MyClass mc = new Project.MyClass();
        }
    }
    namespace MyCompany
    {
        namespace Project
        {
            public class MyClass { }
        }
    }
}
289 questions
0
votes
0 answers

AngularJs 1.X custom directive in separated file is not working

Hi I'm trying to separate the code of a custom directive to manage checkboxes to a different file, but is not working and also it seems that is not loading when I debug with devtools I'm not able to see this new file. not.js (function () { 'use…
user2246242
  • 101
  • 1
  • 12
0
votes
0 answers

is using namespace foo inside a class acceptable?

I know that we should not add a code like this in a header file: using namespace std; but what about this: namespace foo { class A { public: void add() { using namespace std; // do some work…
mans
  • 17,104
  • 45
  • 172
  • 321
0
votes
5 answers

Visual Studio C# does not allow me to use Microsoft.AspNet.Identity namespace

Why is my application not letting me use the following namespace: using Microsoft.AspNet.Identity; Is there any way I can get rid of this in Visual Studio 2015?
Uchiha Itachi
  • 1,251
  • 1
  • 16
  • 42
0
votes
1 answer

Need help creating modular, plug-and-play type directives for an AngularJS mortgage app

I'm pretty new to Angular (and JS for that matter), and am trying to wrap my head around scope, controllers, and directives. I am currently working on a Comparative Mortgage app that will allow a user to compare the cost of two loans. Ideally, each…
0
votes
1 answer

Type or namespace name could not be found (missing using directive or assembly reference?)

With this code: using System.Web.Http; class MyClass : IHttpActionResult { ... } I get the error: The type or namespace name 'IHttpActionResult' could not be found (are you missing a using directive or an assembly reference?) As shown here, the…
Pietro
  • 12,086
  • 26
  • 100
  • 193
0
votes
1 answer

Multiple directives sharing same scope

I have developed a directive, but it is always applying functionality on the last element in the page, here is my code: HTML:
maverickosama92
  • 2,685
  • 2
  • 21
  • 35
0
votes
1 answer

angularjs accessing controller variables in directive

I have a controller and a directive. I'm trying to access the controller's variables in the directive but it doesn't seem to be binding. here is a snippet of the controller: myapp.controller('AddDatasetModalController', ['$rootScope', '$scope',…
alessandro ferrucci
  • 1,261
  • 2
  • 24
  • 48
0
votes
2 answers

Angular: function call as attribute value for directive

This is a reduction of my directive: app.directive('myDirective', function() { return { restrict: 'E', replace: true, template: '
' + '
MarcoS
  • 17,323
  • 24
  • 96
  • 174
0
votes
1 answer

Angular JS: How to open a tab from outside it's directive

I have followed a tutorial on creating tabs in angular, please see a simplified plunkr of my actual code here: https://embed.plnkr.co/ysWI0pSeBVGEi8Iok2mY/ My tabs are working great and i can toggle between them, however I now want to set tabs to…
0
votes
2 answers

Error in angular 2 directives

I am facing this error while I am trying to import directive in component GET http://localhost:3000/@angular/core 404 Error: Error: XHR error (404 Not Found) loading http://localhost:3000/@angular/core(…) Can someone help me on this?
0
votes
1 answer

Angular scope modification inside transcluded content

Angular: Can anyone explain why transcluded content in a directive can only update objects on the scope - not variables directly on the scope. Is it just because the object and functions are ref type in javascript and why does the binding work one…
0
votes
1 answer

ng-class conditional expression not working in directive template

I have created a directive that gets two values from its controller. The ng-class is supposed to apply a class to the stars that are less or equal to the value. It is not doing as I expected. Directive:
Aaron
  • 2,364
  • 2
  • 31
  • 56
0
votes
3 answers

Use outsideClick to close custom directive popover

I have a popover as a custom directive that opens when an icon is clicked or hovered upon. When the icon is clicked the popover sticks, and will close if you click the icon again. Now I want to close the popover after it's clicked by clicking…
0
votes
2 answers

Do objects with SqlConnecions as private fields get closed if the object is in an using block?

I know that using an SqlConnection inside a using block like below will close the connection at the end of the using block. using (var connection = factory.NewSqlConnection()) { //code } I want to know if an object that has a SqlConnection…
James Madison
  • 337
  • 1
  • 4
  • 17
0
votes
1 answer

Passing function into angular directive

I want to pass a function that returns a promise into my directive. Currently I am doing as follows: Callback created in parent controller: $scope.myCb = function(data) { console.log(data); } Scope of Directive: scope { dataCallback:…
Shawn
  • 667
  • 8
  • 19