angularjs-directive

ng-model not updating inside Modal

谁说我不能喝 提交于 2019-12-09 12:11:50
问题 ng-model which i am assigning is controller can be seen inside modal.But when i am updating the data inside the modal,the $scope variable is not updating. Also dropdown is not working whose value i have defined in my controller. Do i need to make changes in directive. <div ng-controller="MainCtrl" class="container"> <h1>Modal example</h1> <button ng-click="toggleModal()" class="btn btn-default">Open modal</button> <modal title="Login form" visible="showModal"> <div> <select ng-model="client"

Sub menu (expanded/collapsed tree) in AngularJS

白昼怎懂夜的黑 提交于 2019-12-09 11:47:56
问题 I have for the past day got stuck on finding the best way to use angular to control a menu list with sub-menus. With jQuery you can just listen after a click event on a specific type of element like a <li> and add a class to its child element for a menu to open. I'm trying to do the same thing like the menu on this page http://geedmo.com/themeforest/wintermin/dashboard.html, with Angular. But can't find the correct way by using my own directive or existing ones like ng-hide and ng-show. If

Link to .cshtml view from javascript

允我心安 提交于 2019-12-09 11:13:11
问题 How can you point directly to a .cshtml view from javascript file? For example why can't I use a .cshtml view with angular.js? like in this example: .directive('encoder', ($timeout) => { return { restrict: 'E', transclude: true, scope: 'isolate', locals: { service: 'bind' }, templateUrl: 'encoderTemplate.cshtml' // <-- that's not possible? } }); It's of course possible to have an action method that returns whatever you want, but I'm curious if it's possible to reference directly to the razor

Breadcrumbs in Angular

六眼飞鱼酱① 提交于 2019-12-09 10:09:01
问题 I want to use Angular's breadcrumb capability. I added this javascript file to my services folder. I added a div to my header.html file to call the javascript. According to Angular, the div should look like this: <div> <ul class="breadcrumb"> <li ng-repeat="breadcrumb in breadcrumbs.getAll()"> <span class="divider">/</span> <ng-switch on="$last"> <span ng-switch-when="true">{{breadcrumb.name}}</span> <span ng-switch-default><a href="{{breadcrumb.path}}">{{breadcrumb.name}}</a></span> </ng

Sharing data between AngularJS controllers? [duplicate]

随声附和 提交于 2019-12-09 09:43:22
问题 This question already has answers here : Can one AngularJS controller call another? (13 answers) Closed 6 years ago . How do I store the items I've selected in a checkbox with other controllers? My attempt (see the plnkr for views): script.js (controllers) var myApp = angular.module('myApp', []); myApp.factory('CooSelection', function () { return {selectedCoo: []} }) function CooListCtrl($scope, CooSelection) { $scope.coos = {"Coos": ["spark", "nark", "hark", "quark"]}; $scope.coo_list

Passing variable to directive template without creating new scope

落爺英雄遲暮 提交于 2019-12-09 07:36:10
问题 Is there a way to pass variables using attributes to a directive without creating a new scope ? HTML <div ng-click='back()' button='go back'></div> JS .directive('button', function () { return { scope: { button: '@' }, template: "<div><div another-directive></div>{{button}}</div>", replace: true } }) The problem is that the ng-click='back()' now refers to the directive scope. I still can do ng-click='$parent.back()' but it's not what I want. 回答1: By default, directives do not create a new

AngularJS - what are the major differences in the different ways to declare a service in angular?

我只是一个虾纸丫 提交于 2019-12-09 06:59:01
问题 I am working on an angularJS app and I am trying to stick with the most efficient and widely accepted styles of development in AngularJs. Currently, I am using this way of declaring my services like so: app.factory('MyService', function() { /* ... */ function doSomething(){ console.log('I just did something'); } function iAmNotVisible(){ console.log('I am not accessible from the outside'); } /* ... */ return{ doSomething: doSomething }; }); However, there are numerous examples out there and I

How to use <head> tag with Angular directive

和自甴很熟 提交于 2019-12-09 06:41:16
问题 I tried this in my Angular app, but it does not work. So I tried inserting a custom tag( <mytag> ) into the head and made the directive work with this by replacing "head" with "mytag". This however is not really what I intended, because it adds <mytag> to the body instead of the <head> Does anyone know how to make it work with the head-tag? 回答1: I had the same challenge. Make sure that your angular app is initialized on the html tag. Then this solution works out of the box. However for us

Nested directives - cannot pass args to controller method from child directive in Angularjs

喜欢而已 提交于 2019-12-09 06:04:35
问题 I'm having some trouble with nested directives in angularjs. I want to call a controller method from a directive within another directive and am trying to pass arguments to it, however they are undefined. I'm attempting to call remove() with three arguments from selected.html below. It was working before I introduced a parent directive (televisionFilter.js) Can anyone suggest what to do to pass these to the controller? Thanks! Code: controller.js $scope.remove = function(selectorToRemove,

Angular directive and Jquery slideToggle function implementation

試著忘記壹切 提交于 2019-12-09 05:52:50
问题 Using angular and jquery I implemented slideToggle function. In order to only apply this function to one specific HTML element, I am using within ng-click function one parameter, my code works fine but, I want to know if exists another better way to implement directives and ng-click functions in angular: index.html <!DOCTYPE html> <html ng-app="myApp" ng-controller="MainController"> <head> <title></title> <link type="text/css" rel="stylesheet" href="css/styles.css"/> </head> <body> <div>