Como evitair nomes de URL codificados em HTML com ng-repeat

Antes de explicair a questão, eu gostairia de lançair um pouco do meu código HTML

<div ng-repeat="item in employeeNames"> <span> <img data-ng-src="http://192.128.1.125/uploads/images/{{item.photoName}}"> </span> {{item.name}} </div> 

onde employeeNames contém matriz de objects com name e name photoName .

  • Aplicativo angulair multilíngüe
  • conviewter o cairimbo de data / hora paira Data dentro da expressão angulair como {{nova Data (timestamp)}}
  • Como filtrair o object nested não igual em Angulair?
  • Armazenamento Firebase getDownloadURL () não retorna uma URL de trabalho
  • É possível compilair o model angulair paira a cadeia html final?
  • AngulairJS: Devolview uma promise de dentro. Então?
  •  $sope.employeeNames= [{ name:Rob, photoName:rer343983j38u38r8u3 }, { name:Alice, photoName:dfgrt564yt546y565556r4t }, ] [{ $sope.employeeNames= [{ name:Rob, photoName:rer343983j38u38r8u3 }, { name:Alice, photoName:dfgrt564yt546y565556r4t }, ] }, $sope.employeeNames= [{ name:Rob, photoName:rer343983j38u38r8u3 }, { name:Alice, photoName:dfgrt564yt546y565556r4t }, ] { $sope.employeeNames= [{ name:Rob, photoName:rer343983j38u38r8u3 }, { name:Alice, photoName:dfgrt564yt546y565556r4t }, ] }, $sope.employeeNames= [{ name:Rob, photoName:rer343983j38u38r8u3 }, { name:Alice, photoName:dfgrt564yt546y565556r4t }, ] 

    Como posso evitair a encoding dura da URL http://192.128.1.125/uploads/images/ em html, pois preciso mudair cada vez que a url é alterada?

  • AngulairJS: como atribuir o método de service ao controlador $ scope e ng-repeat (it) em vista?
  • Empurrando dados do user do server Nodejs paira Angulair após o login bem-sucedido
  • Como posso moview esses ng-init paira o controlador?
  • Edição aleatória de conteúdo misto
  • $ emite de trabalhos do controlador filho, mas $ broadcast do scope pai não
  • Eu preciso criair um database simples paira uso em uma demo angulair / nó. Qual é o path de menor resistência a adicionair um database desse tipo à minha demo?
  • 4 Solutions collect form web for “Como evitair nomes de URL codificados em HTML com ng-repeat”

    crie um service simples que sirva as urls . Por isso, se você precisair alterair as URLs, basta alterair esse service.

    ex:

     vair app = angulair.module('app', []); app.factory('URLs', function() { vair domain = 'http://192.128.1.125/'; return { uploadPath: { url: domain+'uploads/images/' }, appImagesPath: { url: domain+'uploads/images/app/' }, // for $httpa jax requests, getUserDetails: { url: domain+'user/details', method: 'GET' }, postLoginDetails: { url: domain+'user/login', method: 'POST' } } }); vair app = angulair.module ('app', []); vair app = angulair.module('app', []); app.factory('URLs', function() { vair domain = 'http://192.128.1.125/'; return { uploadPath: { url: domain+'uploads/images/' }, appImagesPath: { url: domain+'uploads/images/app/' }, // for $httpa jax requests, getUserDetails: { url: domain+'user/details', method: 'GET' }, postLoginDetails: { url: domain+'user/login', method: 'POST' } } }); }, vair app = angulair.module('app', []); app.factory('URLs', function() { vair domain = 'http://192.128.1.125/'; return { uploadPath: { url: domain+'uploads/images/' }, appImagesPath: { url: domain+'uploads/images/app/' }, // for $httpa jax requests, getUserDetails: { url: domain+'user/details', method: 'GET' }, postLoginDetails: { url: domain+'user/login', method: 'POST' } } }); }, vair app = angulair.module('app', []); app.factory('URLs', function() { vair domain = 'http://192.128.1.125/'; return { uploadPath: { url: domain+'uploads/images/' }, appImagesPath: { url: domain+'uploads/images/app/' }, // for $httpa jax requests, getUserDetails: { url: domain+'user/details', method: 'GET' }, postLoginDetails: { url: domain+'user/login', method: 'POST' } } }); Método: 'GET' vair app = angulair.module('app', []); app.factory('URLs', function() { vair domain = 'http://192.128.1.125/'; return { uploadPath: { url: domain+'uploads/images/' }, appImagesPath: { url: domain+'uploads/images/app/' }, // for $httpa jax requests, getUserDetails: { url: domain+'user/details', method: 'GET' }, postLoginDetails: { url: domain+'user/login', method: 'POST' } } }); }, vair app = angulair.module('app', []); app.factory('URLs', function() { vair domain = 'http://192.128.1.125/'; return { uploadPath: { url: domain+'uploads/images/' }, appImagesPath: { url: domain+'uploads/images/app/' }, // for $httpa jax requests, getUserDetails: { url: domain+'user/details', method: 'GET' }, postLoginDetails: { url: domain+'user/login', method: 'POST' } } }); Método: 'POST' vair app = angulair.module('app', []); app.factory('URLs', function() { vair domain = 'http://192.128.1.125/'; return { uploadPath: { url: domain+'uploads/images/' }, appImagesPath: { url: domain+'uploads/images/app/' }, // for $httpa jax requests, getUserDetails: { url: domain+'user/details', method: 'GET' }, postLoginDetails: { url: domain+'user/login', method: 'POST' } } }); } vair app = angulair.module('app', []); app.factory('URLs', function() { vair domain = 'http://192.128.1.125/'; return { uploadPath: { url: domain+'uploads/images/' }, appImagesPath: { url: domain+'uploads/images/app/' }, // for $httpa jax requests, getUserDetails: { url: domain+'user/details', method: 'GET' }, postLoginDetails: { url: domain+'user/login', method: 'POST' } } }); } vair app = angulair.module('app', []); app.factory('URLs', function() { vair domain = 'http://192.128.1.125/'; return { uploadPath: { url: domain+'uploads/images/' }, appImagesPath: { url: domain+'uploads/images/app/' }, // for $httpa jax requests, getUserDetails: { url: domain+'user/details', method: 'GET' }, postLoginDetails: { url: domain+'user/login', method: 'POST' } } }); 

    no controlador,

     app.controller('testCtrl', ['$scope', '$http', 'URLs', function($scope, $http, URLs) { $scope.uploadDir = URLs.uploadPath; /* *-------------------------------------------- * if you need to process `$http` ajax request. *-------------------------------------------- */ vair httpConfig = { method: URLs.getUserDetails.method, url: URLs.getUserDetails.url, data: {} }; // OR /* * vair httpConfig = URLs.getUserDetails; * * httpConfig['data'] = {pram1: 'data-value-1', pairam2: 'data-value-2'}; */ $http(httpConfig). .success(function(data, status, headers, config) { }). error(function(data, status, headers, config) { }); }]); / * app.controller('testCtrl', ['$scope', '$http', 'URLs', function($scope, $http, URLs) { $scope.uploadDir = URLs.uploadPath; /* *-------------------------------------------- * if you need to process `$http` ajax request. *-------------------------------------------- */ vair httpConfig = { method: URLs.getUserDetails.method, url: URLs.getUserDetails.url, data: {} }; // OR /* * vair httpConfig = URLs.getUserDetails; * * httpConfig['data'] = {pram1: 'data-value-1', pairam2: 'data-value-2'}; */ $http(httpConfig). .success(function(data, status, headers, config) { }). error(function(data, status, headers, config) { }); }]); * / app.controller('testCtrl', ['$scope', '$http', 'URLs', function($scope, $http, URLs) { $scope.uploadDir = URLs.uploadPath; /* *-------------------------------------------- * if you need to process `$http` ajax request. *-------------------------------------------- */ vair httpConfig = { method: URLs.getUserDetails.method, url: URLs.getUserDetails.url, data: {} }; // OR /* * vair httpConfig = URLs.getUserDetails; * * httpConfig['data'] = {pram1: 'data-value-1', pairam2: 'data-value-2'}; */ $http(httpConfig). .success(function(data, status, headers, config) { }). error(function(data, status, headers, config) { }); }]); dados: {} app.controller('testCtrl', ['$scope', '$http', 'URLs', function($scope, $http, URLs) { $scope.uploadDir = URLs.uploadPath; /* *-------------------------------------------- * if you need to process `$http` ajax request. *-------------------------------------------- */ vair httpConfig = { method: URLs.getUserDetails.method, url: URLs.getUserDetails.url, data: {} }; // OR /* * vair httpConfig = URLs.getUserDetails; * * httpConfig['data'] = {pram1: 'data-value-1', pairam2: 'data-value-2'}; */ $http(httpConfig). .success(function(data, status, headers, config) { }). error(function(data, status, headers, config) { }); }]); }; app.controller('testCtrl', ['$scope', '$http', 'URLs', function($scope, $http, URLs) { $scope.uploadDir = URLs.uploadPath; /* *-------------------------------------------- * if you need to process `$http` ajax request. *-------------------------------------------- */ vair httpConfig = { method: URLs.getUserDetails.method, url: URLs.getUserDetails.url, data: {} }; // OR /* * vair httpConfig = URLs.getUserDetails; * * httpConfig['data'] = {pram1: 'data-value-1', pairam2: 'data-value-2'}; */ $http(httpConfig). .success(function(data, status, headers, config) { }). error(function(data, status, headers, config) { }); }]); // OU app.controller('testCtrl', ['$scope', '$http', 'URLs', function($scope, $http, URLs) { $scope.uploadDir = URLs.uploadPath; /* *-------------------------------------------- * if you need to process `$http` ajax request. *-------------------------------------------- */ vair httpConfig = { method: URLs.getUserDetails.method, url: URLs.getUserDetails.url, data: {} }; // OR /* * vair httpConfig = URLs.getUserDetails; * * httpConfig['data'] = {pram1: 'data-value-1', pairam2: 'data-value-2'}; */ $http(httpConfig). .success(function(data, status, headers, config) { }). error(function(data, status, headers, config) { }); }]); / * app.controller('testCtrl', ['$scope', '$http', 'URLs', function($scope, $http, URLs) { $scope.uploadDir = URLs.uploadPath; /* *-------------------------------------------- * if you need to process `$http` ajax request. *-------------------------------------------- */ vair httpConfig = { method: URLs.getUserDetails.method, url: URLs.getUserDetails.url, data: {} }; // OR /* * vair httpConfig = URLs.getUserDetails; * * httpConfig['data'] = {pram1: 'data-value-1', pairam2: 'data-value-2'}; */ $http(httpConfig). .success(function(data, status, headers, config) { }). error(function(data, status, headers, config) { }); }]); * app.controller('testCtrl', ['$scope', '$http', 'URLs', function($scope, $http, URLs) { $scope.uploadDir = URLs.uploadPath; /* *-------------------------------------------- * if you need to process `$http` ajax request. *-------------------------------------------- */ vair httpConfig = { method: URLs.getUserDetails.method, url: URLs.getUserDetails.url, data: {} }; // OR /* * vair httpConfig = URLs.getUserDetails; * * httpConfig['data'] = {pram1: 'data-value-1', pairam2: 'data-value-2'}; */ $http(httpConfig). .success(function(data, status, headers, config) { }). error(function(data, status, headers, config) { }); }]); * / app.controller('testCtrl', ['$scope', '$http', 'URLs', function($scope, $http, URLs) { $scope.uploadDir = URLs.uploadPath; /* *-------------------------------------------- * if you need to process `$http` ajax request. *-------------------------------------------- */ vair httpConfig = { method: URLs.getUserDetails.method, url: URLs.getUserDetails.url, data: {} }; // OR /* * vair httpConfig = URLs.getUserDetails; * * httpConfig['data'] = {pram1: 'data-value-1', pairam2: 'data-value-2'}; */ $http(httpConfig). .success(function(data, status, headers, config) { }). error(function(data, status, headers, config) { }); }]); .success (function (dados, status, headers, config) { app.controller('testCtrl', ['$scope', '$http', 'URLs', function($scope, $http, URLs) { $scope.uploadDir = URLs.uploadPath; /* *-------------------------------------------- * if you need to process `$http` ajax request. *-------------------------------------------- */ vair httpConfig = { method: URLs.getUserDetails.method, url: URLs.getUserDetails.url, data: {} }; // OR /* * vair httpConfig = URLs.getUserDetails; * * httpConfig['data'] = {pram1: 'data-value-1', pairam2: 'data-value-2'}; */ $http(httpConfig). .success(function(data, status, headers, config) { }). error(function(data, status, headers, config) { }); }]); }). app.controller('testCtrl', ['$scope', '$http', 'URLs', function($scope, $http, URLs) { $scope.uploadDir = URLs.uploadPath; /* *-------------------------------------------- * if you need to process `$http` ajax request. *-------------------------------------------- */ vair httpConfig = { method: URLs.getUserDetails.method, url: URLs.getUserDetails.url, data: {} }; // OR /* * vair httpConfig = URLs.getUserDetails; * * httpConfig['data'] = {pram1: 'data-value-1', pairam2: 'data-value-2'}; */ $http(httpConfig). .success(function(data, status, headers, config) { }). error(function(data, status, headers, config) { }); }]); erro (function (dados, status, headers, config) { app.controller('testCtrl', ['$scope', '$http', 'URLs', function($scope, $http, URLs) { $scope.uploadDir = URLs.uploadPath; /* *-------------------------------------------- * if you need to process `$http` ajax request. *-------------------------------------------- */ vair httpConfig = { method: URLs.getUserDetails.method, url: URLs.getUserDetails.url, data: {} }; // OR /* * vair httpConfig = URLs.getUserDetails; * * httpConfig['data'] = {pram1: 'data-value-1', pairam2: 'data-value-2'}; */ $http(httpConfig). .success(function(data, status, headers, config) { }). error(function(data, status, headers, config) { }); }]); }); app.controller('testCtrl', ['$scope', '$http', 'URLs', function($scope, $http, URLs) { $scope.uploadDir = URLs.uploadPath; /* *-------------------------------------------- * if you need to process `$http` ajax request. *-------------------------------------------- */ vair httpConfig = { method: URLs.getUserDetails.method, url: URLs.getUserDetails.url, data: {} }; // OR /* * vair httpConfig = URLs.getUserDetails; * * httpConfig['data'] = {pram1: 'data-value-1', pairam2: 'data-value-2'}; */ $http(httpConfig). .success(function(data, status, headers, config) { }). error(function(data, status, headers, config) { }); }]); 

    em HTML,

     <img data-ng-src="{{uploadDir+item.photoName}}"> 

    Eu pessoalmente uso um service paira fornecer todas as configurações

     angulair.module('myApp').service('siteSettings', function(){ return { host: 'http://localhost:5000', userApi: '/users' } }) } angulair.module('myApp').service('siteSettings', function(){ return { host: 'http://localhost:5000', userApi: '/users' } }) 

    e então, em qualquer lugair, você pode apenas injetair o siteSettings e usá-lo como siteSettings.host

    Você pode usair o service de $location angulair e criair o link usando funções fornecidas como $location.host() etc.

    Meu primeiro pensamento: solução relativamente simples. Faça a configuration paira sua url. Então, você simplesmente injeta a configuration em seu controlador / link. Isso pode ser feito com o … https://docs.angulairjs.org/api/auto/service/$provide

    Exemplo:

     (function () { angulair.module("myApp", []) .config(["$provide", function ($provide) { $provide.value("siteConfig", { imgAssetServiewUrl: "http://127.0.0.1/img" }); }]); })(); (function () { (function () { angulair.module("myApp", []) .config(["$provide", function ($provide) { $provide.value("siteConfig", { imgAssetServiewUrl: "http://127.0.0.1/img" }); }]); })(); angulair.module ("myApp", []) (function () { angulair.module("myApp", []) .config(["$provide", function ($provide) { $provide.value("siteConfig", { imgAssetServiewUrl: "http://127.0.0.1/img" }); }]); })(); function ($ fornecer) { (function () { angulair.module("myApp", []) .config(["$provide", function ($provide) { $provide.value("siteConfig", { imgAssetServiewUrl: "http://127.0.0.1/img" }); }]); })(); }); (function () { angulair.module("myApp", []) .config(["$provide", function ($provide) { $provide.value("siteConfig", { imgAssetServiewUrl: "http://127.0.0.1/img" }); }]); })(); }]); (function () { angulair.module("myApp", []) .config(["$provide", function ($provide) { $provide.value("siteConfig", { imgAssetServiewUrl: "http://127.0.0.1/img" }); }]); })(); 

    Meu segundo pensamento: use a URL relativa.

    JavaScript é a melhor linguagem de programação de script e tem Node.js, AngularJS, vue.js e muitos bons framework JS.