angularjs

Reuse AngularJS Component in another Module (Dependency Injection)

北战南征 提交于 2021-02-08 07:30:10
问题 how can I reuse a simple angular component via Dependency injection? Component: angular.module("navbar", []).component("nav", function() { console.log("component loaded"); }); Other Module Controller I want to use it in: angular.module('CtrlHome', ['navbar']).controller('HomeController', function($rootScope, $scope) { }); And finally use it in the template <nav></nav> It throws me a "injector modulerr" error. What am I doing wrong here? 回答1: The component isn't defined correctly. The

How to remove object from array within ng-repeat with AngularJS?

十年热恋 提交于 2021-02-08 05:48:47
问题 I am having an array with objects like [{...}, {...}] which I am outputting with ng-repeat. Then I have a delete button with a function to delete it. Is there a simple way to delete it in AngularJS, perhaps with $index? Or I need to specify an ID on every object as an property? 回答1: If you don't apply a filter to reorder or filter your array, you can do this: <div ng-repeat="item in items" ng-click="delete($index)">{{item}}</div> And the delete function: $scope.items = [...]; $scope.delete =

protractor: test for focus of field

房东的猫 提交于 2021-02-08 05:25:16
问题 How can I test if an input field is infocus with protractor? I'm doing this: it('should focus email field', function(){ expect(element(by.model('login.email')).getAttribute('id')).toEqual(browser.driver.switchTo().activeElement().getAttribute('id')); }); This seems to work with chrome, but this test fails with firefox. Any ideas? This is the failure message: [firefox #1] 2) Login page should focus email field [firefox #1] Message: [firefox #1] Expected 'login' to equal ''. [firefox #1]

templateRequest fallback in AngularJS

跟風遠走 提交于 2021-02-08 05:01:44
问题 I have the following service I use to pull out a template for a state in my AngularJS application: .factory('templateService', ['$templateRequest', '$translate', function($templateRequest, $translate) { return { getTemplate: function(stateParams, url) { return $templateRequest( 'partials/' + url + '-' + ( $translate.use() ? $translate.use() : $translate.preferredLanguage ) + '.html'); } } }]); and this is it in use: .state('section3', { parent: 'maincontent', url: '/section3', views: {

templateRequest fallback in AngularJS

对着背影说爱祢 提交于 2021-02-08 05:01:06
问题 I have the following service I use to pull out a template for a state in my AngularJS application: .factory('templateService', ['$templateRequest', '$translate', function($templateRequest, $translate) { return { getTemplate: function(stateParams, url) { return $templateRequest( 'partials/' + url + '-' + ( $translate.use() ? $translate.use() : $translate.preferredLanguage ) + '.html'); } } }]); and this is it in use: .state('section3', { parent: 'maincontent', url: '/section3', views: {

Angular JS Smart Table Filtered collection

自闭症网瘾萝莉.ら 提交于 2021-02-08 03:42:25
问题 Where is the filtered collection after filtered value in smart table. the table is bound with rowCollection . <table st-safe-src="rowCollection" st-table="displayed" class="table table-bordered"> and i have used a search filter: <input type="text" id="regionFilter" st-search="region" /> after the result are filtered i still see all records in rowCollection 回答1: You can create a directive to access the get the filtered Collection. For example: HTML: <table st-table="displayedCollection" st

AngularJS SSL .htaccess woes

佐手、 提交于 2021-02-08 02:12:24
问题 I'm trying to enable the use of SSL on my .htaccess file that has already been set up for html5Mode direct linking but it's always resulting in a redirect loop. The closest question I've found on stackoverflow is this but even from here I can't figure it out (I'm new to htaccess files). AngularJS html5Mode direct linking htaccess file is RewriteEngine on RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^ index.html [L] and this works

AngularJS SSL .htaccess woes

一个人想着一个人 提交于 2021-02-08 02:05:21
问题 I'm trying to enable the use of SSL on my .htaccess file that has already been set up for html5Mode direct linking but it's always resulting in a redirect loop. The closest question I've found on stackoverflow is this but even from here I can't figure it out (I'm new to htaccess files). AngularJS html5Mode direct linking htaccess file is RewriteEngine on RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^ index.html [L] and this works

Can't set datepicker date from controller in AngularJS

ぃ、小莉子 提交于 2021-02-07 21:36:23
问题 I am trying to create an AngularJS datepicker on the push of a button. I am using this bootstrap-ui control. The control works (pops up on the click of a button, and I can select a date), but I can't seem to set the initial date back from the scope (so that when it is first opened, the designated date is already selected). The error I get in the Chrome console is: Datepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing

Can't set datepicker date from controller in AngularJS

喜你入骨 提交于 2021-02-07 21:36:21
问题 I am trying to create an AngularJS datepicker on the push of a button. I am using this bootstrap-ui control. The control works (pops up on the click of a button, and I can select a date), but I can't seem to set the initial date back from the scope (so that when it is first opened, the designated date is already selected). The error I get in the Chrome console is: Datepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing