angularjs-scope

Extending base directive functionality to other directives

匆匆过客 提交于 2019-12-25 14:06:06
问题 I just wanted to check is this functionality is possible in angularjs. Eg: I have base directive with some common functions but in my whole application all the directives need this functions to be implemented so more code duplication occurs, I am expecting same functionality as extends(inheritance) in Java. Is it possible to achieve this functionality in angularjs.? As per my requirement i can't archive this function by moving this code to services or factory because it is like all of by

How do $scope and this techniques differ in terms of sharing data via services?

南楼画角 提交于 2019-12-25 12:54:32
问题 If you're going to create new code, please don't change the original jsbins I am writing an app in angular 1. Right now I need to create a service I can inject in multiple controllers. I also need the data to be changeable in the various controllers but reflect the changes across the controllers. So I guess what I want are global values that have 2 way binding. I have been using a "var vm = this" technique instead of using $scope. I've read that they are essentially the same aside from syntax

Template-Url Directive Unit Testing without Karma

谁说我不能喝 提交于 2019-12-25 11:54:40
问题 SOLUTION = Solution Plunker I have tried manually passing the template in testing - is it even good way of doing it ? How to make it passes !!!!!!! How to write unit test for Simple directive with template-Url without Using Karma . I have tried following after seeing examples on stack-overflow but no success. Directive app.directive("crazy", function () { return { restrict: "A", templateUrl:"directivetemplate.html" }; }); Spec describe('Directive: crazy', function () { beforeEach(module(

I am trying to inject a partial template in Angular that contains a graph

早过忘川 提交于 2019-12-25 08:26:23
问题 I am creating an Angular application in ASP.NET with partial templates. When I select the menu, and click "Employees", a controller calls a webservice and returns the correct JSON data, and I store it in $scope.message . I've displayed $scope.message on the screen, and everything works. However, I want to feed $scope.message as data source to a D3plus boxplot graph stored in a partial template called employees.html . It does not seem to be working. Perhaps I am making an obvious mistake and

how can I access a variable defined in one controller from the scope of another controller?

痞子三分冷 提交于 2019-12-25 06:55:54
问题 I have the following controllers: HeaderCtrl , NewsFeedCtrl , MainCtrl MainCtrl contains both the other two controllers, which are in the same level. I'm defining an object in authenticationService and update its value in MainCtrl and I update it frequently in NewsFeedCtrl and I want to display its value in the HTML page controlled by HeaderCtrl . when I use this line in my HeaderCtrl : $scope.unreadNum=authenticationService.notificationList.length; and then I use data binding in my HTML page

Display details of selected options in Angularjs

怎甘沉沦 提交于 2019-12-25 06:44:34
问题 I am new to learn AngularJs. How to display adSet details of selected options? Here is my app.js file : app.controller("AddCompaignCtrl", function($scope){ $scope.status = ['active', 'inactive', 'closed']; $scope.objectives = ['obj1', 'obj2', 'obj3', 'obj4']; $scope.selectedCompaign = "Default-Campaign name"; $scope.selectedCompaign_id =0 $scope.compaigns = [ { id: 0, name: 'testCompaign 0', detail: { status : 'active', objective: 'obj1' }, adsets:[{ name :"adset 01", status:"active", budget:

how to access object property via isolate scope without two-way binding?

只愿长相守 提交于 2019-12-25 06:25:13
问题 I want to pass a product's id to a directive like so: <widget product-id="product.id"></widget> I prefer not to use curly braces: <widget product-id="{{product.id}}"></widget> because it's more verbose, and I want to match the style of ng-model usage. I want to use isolate scope so that I can't accidentally modify product.id inside the widget. If I use: scope { productId: '@' } Then in my directive template: {{productId}} gives me the string "product.id" If I use: scope { productId: '&' } I

Angularjs custom validation directive Async call real time validation

不问归期 提交于 2019-12-25 06:05:07
问题 I am using custom validation directive to validate a field in a form and the validation process includes a AJAX call to verify user information with server API. We want to validate the field as long as user stops typing for a certain period of time. I have two questions: 1.Why is the function below not working?(with link function in the custom directive) The log message was never shown no matter how many times I type in the binded input field (I am pretty sure I enabled log message display

Pass parameter to Angularjs controller function from directive

别等时光非礼了梦想. 提交于 2019-12-25 06:01:09
问题 I have a AngularJs directive that creates a property and callback function on its isolated scope: .directive('testButton', [function () { return { restrict: 'A', controller: 'TestDirectiveController as vmDirective', scope: { myCallBack:'&myCallBack', myVariable: '=myVariable' }, template: function (element, attrs) { return '<button data-ng-click="vmDirective.onButtonClicked(2)">Set myVariable = 2</button>'; } };}]) In the directive a button gets clicked and it executes the onButtonClicked

angularjs give all html elements of a specific type their own scope

爱⌒轻易说出口 提交于 2019-12-25 05:46:09
问题 I need to do this to make use of the <dialog> tag in HTML5, I want every <dialog> on my site to have its own unique scope accessible using the controller and controllerAs syntax. Here is what I thought would work. Javascript \\Dialog Controller function dialog () { return { scope: {}, controller: function () { this.test = 'Dialog Test'; }, controllerAs: 'Dialog', bindToController: true } } angular.module('app',[]).directive('dialog', dialog); HTML <!-- Dialog HTML Example Case --> <body ng