angularjs-directive

How to form the Query string in web address url in Angular state router by using state go method

泪湿孤枕 提交于 2019-12-04 05:51:52
问题 I have a product list page, there have list of products,when click the particular products, call the function and in the function state.go. Not working in dynamic: $state.go('home.product.detail', { 'productID': "redminote4", 'brand': 'x', "store":"amazon" }); .state('home.product.detail', { url: '/products/:?productID?brand?store', views: { '@': { templateUrl: baseUrl + 'products/products', controller: 'productsController' } }, data: { displayName: '', displayImg: 'Images/productsHeaderIcon

AngularJS Wrapping a ui-select in a custom directive

主宰稳场 提交于 2019-12-04 05:45:23
I'm trying to wrap a ui-select in a custom directive. ( https://github.com/angular-ui/ui-select ) this.adminv2.directive('eventSelect', function() { return { restrict: 'E', replace: true, scope: { ngModel: '=', placeholder: '=' }, controller: function($scope, $http) { return $scope.refreshEvents = function(searchTerm) { return $http.get('/events/autocomplete', { params: { term: searchTerm } }).then(function(response) { return $scope.events = response.data; }); }; }, template: "<div>{{ngModel}}\n <ui-select ng-model=\"ngModel\"\n theme=\"bootstrap\"\n ng-disabled=\"disabled\"\n reset-search

Angular directive with scope.$watch to force validation of other fields

最后都变了- 提交于 2019-12-04 05:41:57
I've written a match-model Angular directive that I use for password/password-repeat process when users register in my application. Password repeat field has this particular attribute that validates this field against original password field. My directive has scope.$watch for optimization purposes because I don't have to read related scope property value each time I validate my repeat password scope property but I rather just use cached value which changes when related scope property value changes (original password). This is my directive: .directive("matchModel", ["$timeout", function (

Angularjs use custom interpolation symbols for scope

孤人 提交于 2019-12-04 05:39:28
I currently have an underscore.js template that I would also like to use with angular and still be able to use with underscore. I was wondering if it's possible to change the interpolation start and end symbols for a particular scope using a directive, like this: angular.directive('underscoreTemplate', function ($parse, $compile, $interpolateProvider, $interpolate) { return { restrict: "E", replace: false, link: function (scope, element, attrs) { $interpolateProvider.startSymbol("<%=").endSymbol("%>"); var parsedExp = $interpolate(element.html()); // Then replace element contents with

Bind events on AngularJS element directives using jQuery

淺唱寂寞╮ 提交于 2019-12-04 05:31:26
I have a directive in AngularJS: module = angular.module("demoApp", [], null); module.directive('sample', function () { return { restrict: "E", transclude: true, replace: true, template: "<div ng-transclude></div>", controller: function ($scope, $element) { this.act = function (something) { //problematic line HERE $element.trigger("myEvent.sample", [something]); }; } }; }) .directive('item', function () { return { restrict: "E", require: "^sample", transclude: true, replace: true, template: "<a ng-transclude style='display: inline-block; border: 1px solid crimson; margin: 2px; padding: 5px;

Directive with root element with ngRepeat and replace: true

隐身守侯 提交于 2019-12-04 05:05:51
问题 Can someone explain the root cause behind the following behavior? If a directive with isolate scope scope: {} has a root element with ng-repeat AND replace: true then it "breaks" the isolate scope, meaning that the isolate scope is not accessible/visible from within the directive, and the directive starts receiving variables from the outer scope. Here's the minimally reproducible example I could make: app.controller('MainCtrl', function($scope) { $scope.name = 'MainCtrl'; }); app.directive(

Listen for form submit event in directive

我只是一个虾纸丫 提交于 2019-12-04 04:55:55
I want to listen for form submitting in a directive. Say I have a directive like this: app.directive('myDirective', function () { return { restrict: 'A', require: '^form', scope: { smth: '=' }, link: function (scope, el, attrs, formCtrl) { scope.$watch(function(){ return formCtrl.$submitted; },function(currentValue){ console.log('submitted'); }); } } }); With the above method I can watch for first submit, but not the rest. I tried to do something like this: scope.$watch(function () { return formCtrl.$submitted; }, function (currentValue) { if (currentValue) { console.log('submitted'); formCtrl

Angular minification with directive controller?

元气小坏坏 提交于 2019-12-04 04:46:27
If I have the following: myapp.directive('directivename', ... return { ... restrict: 'E', controller: MyController, ... } function MyController($scope, $somethingelse) { // Contents of controller here } ); How do I modify this such that MyController will not get destroyed when minified? I am getting the following error: Error: [$injector:unpr] Unknown provider: eProvider <- e PSL It can be resolved by using explicit dependency annotation. What you have it implicit annotation which causes issues while minification. You could use $inject or inline array annotation to annotate the dependencies in

angularjs : @mention in textarea

老子叫甜甜 提交于 2019-12-04 04:40:54
I want to display an autocomplete form triggered by the word @ in my textarea like this library http://ichord.github.io/At.js/ but only using angularjs & css What kind of directive should I write ? Also, is there a way to implement this with the angular bootstrap UI typehead directive ? See https://github.com/jeff-collins/ment.io for a directive that likely does what you are looking for. I've written angular-otobox , a dependency-less angular directive for mentioning, tagging and higlighiting words in text, it's easy to use. have look, it's easy to use. 来源: https://stackoverflow.com/questions

AngularJS : directives and scope

旧城冷巷雨未停 提交于 2019-12-04 04:38:51
问题 I have a simple question that I think has a pretty simple solution, but somehow I am missing it. I'm setting up a simple directive for my app. I'm leaving the scope property set to the default, "false", because I want it to share the scope of my controller. The problem is, I can't seem to access that scope. In my linking function, I can do: console.dir(scope) and I can see the property that I am after ('pages') in the scope object. If I try to do: console.dir(scope.pages) however, it comes