Questions tagged as 'javascript'

2
answers

Add code before / head and after body

I need a fuzzy javascript that adds this code before closing the tag </head> <link rel="stylesheet" type="text/css" href="http://cdn.grupospotlight.com/nav/navbar.css"> And this soon after the tag <body>...
asked by 04.12.2016 / 19:34
1
answer

how to change an image src from another page

Hello, I have an input where it serves as a search bar. When entering a name and pressing enter, a function is activated and performs the following function: function verificaValor(){ var valor = $('#search').val(); switch (valor) {...
asked by 20.11.2016 / 04:50
3
answers

I need to check if my JSON is empty to fetch url with parameter defined in the curl

function BuscaMarca(marca, modelo, anomodelo) { marca = $('#marca').val(); tipo = $('#tipo').val(); $.get("curl.php?tabela=BuscaMarca&marca=" + marca + "&tipo=" + tipo, function(data, status) { if (data == 0) {...
asked by 27.10.2016 / 15:30
1
answer

Validation of two selects

I have two fields select , one I have states and another cities. I need to select in a select a state, eg: São Paulo and in the other select only bring the cities of são paulo.     
asked by 28.10.2016 / 19:41
1
answer

Split "100000000000" in JQUERY [closed]

I need to separate all the characters of a string into an array, and I have a problem, my code is as follows var PISCampos = campos.split(""); When I send in the variable fields the following string: "011001000000". Everything works, and I...
asked by 20.10.2016 / 17:12
1
answer

Calculator with JavaScript validation (I can not find the error)

             Calculator <style type="text/css"> #div1{ text-align:center; border:1px solid black; width:20%; height:200px; position:absolute; left:40%;...
asked by 10.11.2016 / 22:37
1
answer

Call 2 events on onclick

I'm developing a website, and I need to trigger 2 events when a text is clicked. A js function, and a google analytics goal tracking code. Here's an example function shownumber() { document.getElementById("number").innerHTML = "<sm...
asked by 12.11.2016 / 19:59
4
answers

___ ___ erkimt Sharing the variable $ scope from one controller to another with parameters in AngularJS ______ qstntxt ___

I have this:

%pre%

I wanted my second controller to get the $ scope.getIdJobs variable and save it to a variable again. How can I do this?

%pre%

app.js

%pre%     
______ azszpr165042 ___

A simple solution is to have a factory that returns the value that you need (an object for example): JS:

%pre%

HTML:

%pre%

Demo: link

When applications get larger, more complex, and harder to test, you may not want to expose the entire object of a factory in this way, but instead give limited access for example via getters and setters:

%pre%

With this approach controllers consume the service with new values and use $ watch to observe the changes:

%pre%

HTML:

%pre%

Demo: link

    
______ azszpr164875 ___

I'm a beginner too but I'll try to help you by giving two tips:

  • There is %code% that holds information and when loaded can be passed from controllers to controllers, much used for IDs.

  • Another way would be to store this %code% in a service and then use it in other controllers by calling it: %code%

  • ______ azszpr164891 ___

    You can put the products variable in $ rootScope, so you can access it for $ rootScope anywhere. But I advise you to use the ui-router to make the parameters pass, it gets more cohesive and with less chances of you having undesirable variable value substitution problems, or something like that.

    You should set the parameter in your state:

    %pre%

    And it will pass it this way:

    %pre%     
    ______ azszpr165044 ___

    Good,

    In my opinion it is advisable to create a %code% for the date, which will be %code% , where you can encapsulate the date and its %code% . Then just call the %code% you need in the controllers.

    Here's the example in this jsfiddle

    %pre%

    In the controller that accesses %code% you call the %code% method.

    %pre%

    In the second controller, just declare %code% or if necessary you can filter again with a new id.

    %pre%

    In this way, you can clear the %code% , and everything relative to that date can be reached in %code% and %code% easily.

    Or you will have the option of %code% , which also works for what you want.

    About routers, I advise you to take a look at ui-router , a far superior tool in my understanding.

        
    ___

    I have this: $scope.products = []; $http.get('app/components/job/controller/teste.json').success(function (resource) { $scope.products = resource; }); $scope.getIdJobs = function(getIdJobs) { var result = $filter('filter')(...
    asked by 11.11.2016 / 10:55
    1
    answer

    doubt Array.push () Javascript

    Hello! Can anyone tell me why the push method is only saving the last item in the newArr array? My goal is to extract an array with the permutation of the passed values and in console.log() it comes out right, but when I try to th...
    asked by 02.02.2017 / 19:04
    1
    answer

    Customize volume player bar html5

    Friends, I have an html5 player with all standard controllers. I would like to make a volume controller in that same style: Mycodesofar <audio id="demo" src="http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3"></audio>&l...
    asked by 31.01.2017 / 16:28