angularjs-directive

Angular: Looking for an explanation on custom directive syntax

谁说胖子不能爱 提交于 2019-12-24 05:57:55
问题 I copied a custom directive that watches for changes on form file inputs. angular.module('customDirective', []) .directive('ngFileInputChange', function() { return { restrict: 'A', link: function (scope, element, attrs) { var onChangeHandler = scope.$eval(attrs.ngFileInputChange); element.bind('change', onChangeHandler); } }; }); Then I use it in the template like so: <input ng-model="vm.image" ng-file-input-change="vm.base64Test" ...> And this works fine. However, this doesn't work: <input

Trying to change the material md-selected tab using custom code from directive using two way data binding

末鹿安然 提交于 2019-12-24 05:23:04
问题 I'm trying to change the tab using code and can't seem to figure out the error. The basic thing works if we use the controller to change the variable but when I try to bind it through directive, it brokes. var app = angular.module('MyApp', ['ngMaterial']); app.controller('HelloCtrl', function($scope) { $scope.selectedTab = 0; }); app.directive('something', function() { return { restrict: 'E', template: '<div ng-click="changeNavigation()">Change Navigation</div>', scope: { selectedTab: '=' },

Angularjs ng-repeat creating multiple forms

时间秒杀一切 提交于 2019-12-24 03:32:31
问题 Using ng-repeat I am creating bunch of forms with values in it. With each form there is also button to add rows to that particular form with new fields. Code is below HTML: <div ng-repeat="cont in contacts"> <form ng-submit="newContact()"> <input type="text" class="xdTextBox" ng-model="cont.ac"/> <input type="text" class="xdTextBox" ng-model="cont.cat"/> <input type="text" class="xdTextBox" ng-model="cont.loc"/> <button type="submit">Submit</button> <a href ng-click="addFields()">Add</a> <

Perform Group By and Sum by property in angularjs

心不动则不痛 提交于 2019-12-24 03:29:27
问题 Ok so have a simple page that displays a collection of objects in using ng-repeat="(key, value) in data| groupBy: 'Id'" I would like to group the data by a known property and also perform aggregate sum on one of the fields. I've used the angular-filter.js library leveraging the groupBy filter to facilitate this. The issue now is that I would like to also perform the aggregate sum and also display only a single row for each group. so say I have an array of objects, `[{Id:1,name:"harry",volume

Angular UI router not working

二次信任 提交于 2019-12-24 03:16:25
问题 **This js file for the ui router is proper or not.The error displaying is "Error: Unknown provider: $stateProvider from routerApp" this js files have been loaded in the Html file. ** var routerApp = angular.module('routerApp', ['ui.router']); routerApp.config(function($stateProvider, $urlRouterProvider) { $urlRouterProvider.otherwise('/template1'); $stateProvider // HOME STATES AND NESTED VIEWS ======================================== .state('template1', { url: '/temp1', templateUrl:

What is the angular way of hiding all specific divs with the same class

元气小坏坏 提交于 2019-12-24 03:00:34
问题 I want to do a simple thing: I have an app, which has certain divs that in need to show (Only the specific one) and hide if clicked somewhere outside of it (All with the specific class for example). This is easy using jquery: $('some-class').style('display','none') //psuedo code here How should i do the same with angular js? A specific reason to do so: I want to build a simple select drop-down (I don't want to use one that exist, i want to understand this...), when i click one, it suppose to

Creating a new html page from controller

喜欢而已 提交于 2019-12-24 02:50:07
问题 I have an input form page, that when the user submits, it updates that page with some tables of data. If the user likes what they see, they should be able to print a cleaned up (no header nav, footer nav, etc) version of those tables with formatting intact. I'm creating the tables using bootstrap and angularjs. What I'm trying to do is that when the uset clicks 'print', my angular controller grabs the desired content from the generated page (in a div called 'template') and inserts it into a

How to filter JSON data based on current date

孤人 提交于 2019-12-24 02:26:11
问题 I wanna ask about angularJS. I have json here var friends = [ { "id":1, "Tanggal":"\/Date(1408060800000)\/", "Nama":"Hari Departemen Agama Republik Indonesia" }, { "id":2, "Tanggal":"\/Date(1388880000000)\/", "Nama":"Hari Korps Wanita Angkatan Laut" }, View <ul> <li ng-repeat="friend in friends | filter:" >{{friend.Tanggal.substr(6,13) | date: 'dd MMMM' }} {{friend.Nama}} </li> </ul> this my controller .controller('FriendsCtrl', function($scope, Friends) { $scope.friends = Friends.all(); }) I

why css is not apply on list using JQM in angular

南笙酒味 提交于 2019-12-24 02:25:25
问题 can you please tell me why my list is not display . I used this https://github.com/angular-widgets/angular-jqm here is the documenetation http://angular-widgets.github.io/angular-jqm/master/docs/#/api/jqm.directive:jqmListview http://plnkr.co/edit/AfUQ5PGjKi12afqgFRfZ?p=preview app.controller('loginCtrl', ['$scope', function(scope){ var friends = [ {name:'John', age:25, gender:'boy'}, {name:'Jessie', age:30, gender:'girl'}, {name:'Johanna', age:28, gender:'girl'}, {name:'Joy', age:15, gender:

angularjs: using a directive inside the ui-bootstrap modal

本秂侑毒 提交于 2019-12-24 01:39:31
问题 I can't figure out how to call a directive from within a modal created with the $dialog service. That directive should also be able to see the buttons on the modal and override their ng-click action. Here's my modal template: <div class="modal-header"> <h1>Rechercher</h1> </div> <div class="modal-body"> <search-person></search-person> </div> <div class="modal-footer"> <button ng-click="close(result)" class="btn btn-primary">Close</button> </div> the searchPerson directive template: <span>{