Introduction

Organic dyes and heavy metal ions are two of the most common water pollutants. Many types of organic dyes are biologically toxic and difficult to degrade, especially that some cationic dyes are more harmful to hydrosphere (Ahmad et al. 2021). Compared to organic dyes, heavy metal ions such as copper and cadmium are more difficult to eliminate, which can be easily accumulate in organisms (Guo et al. 2021). Heavy metal ions are completely non-degradable and always cause irreversible pollution (Rajadurai and Anguraj 2021). It can be enriched in organisms and spread along the food chain, causing heavy metal poisoning at various levels as well as large scales. For these two types of pollutants, the adsorption method for water purification and wastewater treatment is widely studied and applied (Barry et al. 2017; Wu et al. 2020).

Hydrogel is composed of a cross-linked network formed by water-soluble polymers, and a large amount of water swells in this quasi-steady network (Ahmed 2015), which endow it suitable properties to serve as an adsorption material. Due to their special mechanical properties and excellent hydrophilicity, hydrogels are widely used in the preparation and modification of tissue engineering scaffold, water purification materials, oil–water separation membranes, drug delivery system, antifouling film, sensors, adsorption materials (Chu et al. 2015; Zhou et al. 2019a, b; Liu et al. 2021).

In different application scenarios, specific working conditions such as temperature, moisture content, and pH are always required specifically for certain types of hydrogels in order to maintain their stability (Zhou et al. 2019a, b). However, in the practical application scenarios like wastewater treatment, the changing of the conditions and factors is often unpredictable and uncontrollable. Some special covalent bonds can help the material adapt to environment changes. One common type of reversible covalent bonds is the B-O bond between boronic acids and 1,2- or 1,3-diols, which is often used as a synthetic self-healing material (Tarus et al. 2014). However, the formation of B–O always requires relatively high pH (pKa = 8–9, pH > pKa), and most B–O bond-based self-healing behaviors occur in high pH range (pH ~ 8.5) which is sometimes difficult to maintain. 2-aminophenylboronic acid can change its structure to form intramolecular coordination under different pH, which has unique advantages in adapting to special pH environments (Yang et al. 2006; Deng et al. 2018; Smithmyer et al. 2018). We have previously synthesized 2-aminophenylboronic acid-modified hyaluronic acid (HA-2APBA) and prepared HA-2APBA/poly(vinyl alcohol) plus alginate/calcium interpenetrating network (IPN) hydrogels, which possessed both self-healing properties and good biocompatibility (Deng et al. 2018). The preparation of this IPN hydrogel is a bit complicated; hence, a more simplified method is required.

Laponite is a synthetic-layered silicate nanodisk incorporated with inorganic polyphosphate dispersing agent. It hydrates and swells in water to give clear and colorless colloidal dispersions of low viscosity. Haraguchi et al. were the first one to use laponite as a cross-linking agent to form a hydrogel (Haraguchi et al. 2002). Nowadays, laponite has been widely used in drug delivery, 3D bioprinting, bone tissue engineering, and wastewater treatment (Afewerki et al. 2019; Rajabi et al. 2020). It has permanent negative charge, good biocompatibility, high transparency, and good dispersity in water.

Based on the previous work, simpler raw materials polyacrylic acid, poly(vinyl alcohol) and laponite, and simple method could be used to prepare a nanocomposite hydrogel that has various excellent properties while adapting to a wide range of pH changes. Herein, we report a new type of hydrogel prepared by mixing 2-aminophenylboronic acid-modified polyacrylic acid (PAA-2APBA) and poly(vinyl alcohol), as well as the introduction of laponite to form a nanocomposite hydrogel (NCgel). The hydrogel is versatile, biocompatible, injectable, and self-healable, which could gel at a wide range of pH and could efficiently remove the organic dyes and heavy metal ions in model wastewater. With these build-in properties, such type of hydrogel would have great potential application values in the field of wastewater treatment.

Materials and methods

Materials

Polyacrylic acid (Mw = 1 × 105 g/mol, 35 wt% water solution), N-Ethyl-N′-(3-(dimethylamino)propyl) carbodiimide hydrochloride (EDC, 98%), paraformaldehyde, 2-amino phenylboronic acid hydrochloride (95%), poly(vinyl alcohol) (Mw = 85,000 − 124,000, 99 + % hydrolyzed), were all purchased from Sigma-Aldrich (St. Louis, MO, U.S.A.) and were used without further purification. Dulbecco’s modified Eagle’s medium (DMEM) basal medium (high glucose) and fetal bovine serum were obtained from Solarbio (Shanghai, China). The deionized water used in all experiments was purified by a Milli-Q purification system, with a resistivity of > 18.2 MΩ cm. Methylene blue and malachite green were all purchased from Solarbio. Copper sulfate (CuSO4), cadmium chloride (CdCl2), ferric chloride (FeCl3), and lead nitrate (Pb(NO3)2) were obtained from Sinopharm Group Chemical Reagent Co., Ltd. Laponite-XLS XR was purchased from BYK Additives (Shanghai) Co., Ltd. Live/Dead Cell Double Stain Kit (Calcein-AM/PI Double Stain Kit) was obtained from Shanghai Yeasen Biotechnology Co., Ltd. HCl (0.1 M) and NaOH (0.1 M) were used for pH adjustment during the experiment.

Synthesis and characterization of 2-aminophenylboronic acid-modified polyacrylic acid

2-aminophenylboronic acid-modified polyacrylic acid (PAA-2APBA) was synthesized through N-Ethyl-N′-(3-(dimethylamino)propyl) carbodiimide hydrochloride (EDC) chemistry (Fig. 1a). Briefly, polyacrylic acid (1 g, 35 wt% aqueous solution) was dissolved in 150 mL of deionized water. EDC (1 g) was dissolved in 10 mL of deionized water and then added dropwise into the polyacrylic acid solution. The pH was then adjusted to 6.0 by the addition of 0.1 M NaOH and kept with stir for 10 min. Afterward, 170 mg of 2-aminophenylboronic acid dissolved in 5 mL of deionized water was slowly dropped into the mixed solution of polyacrylic acid and EDC under magnetic stirring, while the pH of the reaction mixture was always maintained at 6.0 via addition of 0.1 M NaOH or HCl over the 4 h reaction time at room temperature. The reaction was finally stopped by adjusting the pH to 7.0 using 0.1 M NaOH, after which the PAA-2APBA was purified by dialysis against a large excess of water using a prewashed dialysis membrane (molecular weight cut off, MWCO = 14 kDa). The dialysis was stopped when the conductivity of the dialysate was less than 5 μS·cm−1, after which the PAA-2APBA product was recovered by freeze-drying, and the obtained product was stored at − 20 °C (Deng et al. 2018). In order to investigate the effect of different feeding ratios of carboxyl groups in polyacrylic acid and amino groups in 2-aminophenylboronic acid on hydrogels, three groups of PAA-2APBA was prepared with different molar ratios, namely carboxyl groups: amino groups = 5:1, 2.5:1, and 1:1. For convenience, the PAA-2APBA with different grafting rates was named as precursor5, precursor2.5, and precursor1, and the subsequent hydrogels prepared by different PAA-2APBA were named as gel5 or NCgel5, gel2.5 or NCgel2.5 and gel1 or NCgel1 accordingly.

Fig. 1
figure 1

a Synthesis of 2-aminophenylboronic acid-modified polyacrylic acid (PAA-2APBA) and the hypothesized mechanism of hydrogel formation between PAA-2APBA with poly(vinyl alcohol) at neutral pH; b Preparation of PAA-2APBA/poly(vinyl alcohol) hydrogel and PAA-2APBA/poly(vinyl alcohol) + laponite nanocomposite hydrogel (including the introduction of laponite); c schematic diagram of laponite nanoparticles; d Vial inversion tests of poly(vinyl alcohol) solution (30 mg/mL), PAA-2APBA + laponite solution (30 mg/mL), and gelation after simple mixing of PAA-2APBA + laponite and poly(vinyl alcohol) solutions. ej PAA-2APBA/poly(vinyl alcohol) + laponite hydrogel formation (containing 80% v/v of a 30 mg/mL PAA-2APBA stock solution well mixed with 20% v/v of a 30 mg/mL laponite stock solution, NCgel1) at different pH of the precursor solutions. e pH 2.5; f pH 3.5; g pH 5.5; h pH 7.0; i pH 8.0; j pH 9.0

Preparation of nanocomposite hydrogels

For preparing nanocomposite hydrogels, the precursor solutions of poly(vinyl alcohol) (30 mg/mL) and 2-aminophenylboronic acid-modified polyacrylic acid (PAA-2APBA) + laponite (containing 80% v/v of a 30 mg/mL PAA-2APBA solution well mixed with 20% v/v of a 30 mg/mL laponite stock solution) were first prepared in deionized water. The two precursor solutions were then loaded separately into two barrels of a double-barrel syringe and coextruded through a static mixer into a mold of dimensions specified for each subsequent test (Fig. 1b). In the precursor solution PAA-2APBA + laponite, the proportion of laponite was also increased to 30% v/v and 40% v/v, respectively, to determine the effect of laponite content on the nanocomposite hydrogel.

For convenience, the PAA-2APBA/poly(vinyl alcohol) + laponite hydrogels prepared using the precursor PAA-2APBA with the feeding ratio between carboxyl and amino groups of 5:1 was named ‘NCgel5’. Similarly, NCgel2.5 and NCgel1 were named after the PAA-2APBA precursor.

Characterization of nanocomposite hydrogels

The pH adaptability of hydrogels: The pH of the precursor polymer solution was changed to judge the gelation properties of the hydrogel. Self-healing and injectable performance: The 2.5 mL syringe was used to analyze the injectability of hydrogel, and the rheology was used to study the self-healing behavior of hydrogel. Matrix-assisted laser desorption/ionization time of flight mass spectrometry (MALDI-TOF MS) was used to verify the existence of 2-aminophenylboronic acid-modified polyacrylic acid (PAA-2APBA). The hydrogel was immersed in PBS for degradation experiments. The scanning electron microscope (SEM), transmission electron microscope (TEM), and synchronous thermal analyzer were used to observe the morphology and thermal stability of the nanocomposite hydrogel. Calcein-AM/PI Double Stain Kit was used to verify the biocompatibility of hydrogels. Please see the supplementary information part 1 for detailed steps.

Adsorption of organic dyes and metal ions

The water solution of methylene blue (2 mg/mL) and malachite green (2 mg/mL) were set as the model wastewater containing organic pollutants with positive charges, the pH of the model wastewater was 7. NCgel1 (0.2 g) was placed in the prepared methylene blue solution, and then, 0.2 mL of supernatant of the solution was taken every hour for the first 5 h and 24 h. The absorbance was measured at a wavelength of 665 nm for methylene blue and 625 nm for malachite green with a microplate reader. At 28 h, the adsorbed organic dye was centrifuged, and the supernatant was taken to measure the absorbance value. The measurement was repeated three times for each adsorption experiment (n = 3).

The in situ synthesized nanocomposite hydrogels were used directly added into the solutions to adsorb metal ions, without undergoing the lyophilize step. The mass of the in situ synthesized nanocomposite hydrogels for adsorption was 0.2 g, and the initial concentration of all ions was 2 mg/L, pH = 5 (Pishnamazi et al. 2021). During the adsorption process, the mixture was shaken and sampled at different time points (0, 10, 20, 30, 40, 50, 60 min). After the adsorption is completed, the supernatant was left to stand and the metal ion concentration in the solution was detected by atomic absorption spectrophotometry. The measurement was repeated three times for each adsorption experiment (n = 3). The formula (1) was used to study the adsorption of the hydrogel. Qe (mg/g) were calculated by formula (1) to indicate the adsorption. Ct and Vt were the sampled ion concentrations and the volume of the suspension, respectively, and m was the mass of NCgel1. V0 = 50 mL, and C0 = 2 mg/mL for all metal ions.

$$Q_{e} = \frac{{C_{0} V_{0} - C_{t} V_{t} }}{m}$$
(1)

Results and discussion

Polymer synthesis and hydrogel preparation

Polyvinyl alcohol can react quickly with phenylboronic acid to form hydrogels. In this project, 2-aminophenylboronic acid-modified polyacrylic acid (PAA-2APBA) was synthesized by using an amide bond reaction between –COOH on polyacrylic acid and -NH2 on 2-aminophenylboronic acid (Fig. 1a and Fig. S1). The 2-aminophenylboronic acid can change its own conformation to accommodate a wider pH range (Scheme S1), which enables it to adapt to more complex environments (Deng et al. 2015). Under the excitation of potassium ions, matrix-assisted laser desorption/ionization time of flight mass spectrometry (MALDI-TOF MS) indicated the existence of PAA-2APBA in the precursor polymer1 (Fig. S2). The feed masses of polyacrylic acid and 2-aminophenylboronic acid were 0.35 g and 0.17 g, and the final product (after dialysis and freeze-drying) mass was 0.41 g. The yield was 78.85%.

Nanocomposite hydrogels were subsequently formed by simple mixing of PAA-2APBA + laponite and poly(vinyl alcohol) solutions at neutral, acidic, or alkaline pH via coextrusion through a double-barrel syringe (Fig. 1b). PAA-2APBA/poly(vinyl alcohol) + laponite gelation was assessed using a vial inversion test (Fig. 1d). Solutions of either poly(vinyl alcohol) or PAA-2APBA + laponite did not gel, while gelation occurred quickly (about 1 min) after mixing of PAA-2APBA + laponite and poly(vinyl alcohol) solutions, confirming that boronate-poly(vinyl alcohol) cross-linking occurred. When the volume ratio of laponite solution increased to 40% v/v (PAA-2APBA precursor solution 60% v/v), the transparency of the hydrogel decreased significantly (Fig. S3). In addition, the high grafting rate of precursor1 (see Supplementary Information) performed high cross-linking density in the hydrogel. Therefore, subsequent experiments are performed based on laponite 20% v/v (NCgel1) unless otherwise specified.

pH range

At each of pH 2.5, 3.5, 5.5, 7.0, 8.0, and 9.0 of the precursor solutions, gelation occurred within 1 min after simple mixing the polymer solutions (NCgel1, Fig. 1e–j). At the pH of about 2.5, mixing 2-aminophenylboronic acid-modified polyacrylic acid (PAA-2APBA) + laponite and poly(vinyl alcohol) would generate precipitation of some white solids, since the polyacrylic acid becomes less soluble at low pH (Scheme S2) (Tanaka et al. 1980). While for the PAA-2APBA, some of the carboxyl group were substituted, so it can still cross-link with poly(vinyl alcohol) through borate linkage to form a gel at low pH.

Self-healing and injectable properties

The self-healing property of hydrogel indicates that if the structure of the hydrogel is destroyed through physical or chemical cracking, it can spontaneously repair back into a whole and recover its original function without any external stimuli, which greatly help to extent the lifespan and broaden its operating environment. We used gel1 and NCgel1 to investigate their self-healing characteristics. After healing for three minutes without external pressure, the healed gel could be handled with a tweezer to indicate its mechanical integrity (Fig. 2a). The healed gel could bear its own weight, and the macroscopic size can be restored to the initial state. As for NCgel1, the broken hydrogels could also heal without any external stimulus, restore size, and bear its own weight (Fig. 2b). As mentioned above, the reversible covalent bonds between 2-aminophenylboronic acid and the cis-diols in poly(vinyl alcohol) are a dynamic equilibrium. The broken hydrogel will generate a key rearrangement at the fracture interface by B–O and spontaneously repair into a whole structure.

Fig. 2
figure 2

Self-adhesion of (a) hydrogel (pH = 7.0, gel1) and (b) nanocomposite hydrogel (pH = 7.0, NCgel1); (I) intact hydrogel; (II) cut hydrogel; (III) gel halves placed in contact for three minutes after cutting; (IV) self-adhered hydrogel can suspend its own weight immediately after the two minutes healing time. c, d Rheological properties of hydrogel (gel1, c) and nanocomposite hydrogel (NCgel1, d) in response to a strain sweep at 1.468 Hz initiated at low oscillation displacement (0.02 rad, 120 s) followed by high oscillation displacement (0.5 rad, 120 s), then hydrogels healed 180 s and returned to low oscillation displacement (0.02 rad, 600 s); e, f The injectable properties of nanocomposite hydrogel (NCgel1)

Mechanical testing demonstrated the shear storage modulus (G′) is higher than shear loss modulus (G″), which meant gel1 and NCgel1 behaving as gels (Fig. S4). The rheological results showed the self-healing properties of both gel1 and NCgel1. As shown in Fig. 2c, G′ is higher than G″ from 0 to 120 s at a low oscillation displacement (0.02 rad, 1.468 Hz), which indicated that the materials behaved as gels. From 120 to 240 s, a higher oscillation displacement (0.5 rad, 1.468 Hz) was exerted to damage the structure of hydrogels (G′ decreased from ~ 600 to 50 Pa). At this time, the materials tended to be fluid rather than gels (G″ > G′). After the destroyed hydrogels were allowed to heal for 180 s, the gel showed mechanical recovery at a low oscillation displacement (0.02 rad, 1.468 Hz).

NCgel1 also showed gel behavior and reversibility of self-healing. The G′ of NCgel1 was about 1500 Pa, as compared with 600 Pa of gel1, indicating that laponite could significantly improve the mechanical properties of the hydrogel (Fig. 2d). After the hydrogel structure was destroyed, NCgel1 can still recover to ~ 90% of the initial state within 3 min, ensuring that the mechanical properties of the hydrogel could be recovered.

In addition, we tried to inject the already-formed NCgel1 through the syringe and allowed the squeezed-out gel fractures to form integral gel again. In order to facilitate the distinction, the gels were stained with a red dye (left, sulforhodamine B solution) and blue (right, methylene blue solution) (Fig. 2e). The NCgel1 could be easily extruded through a 0.5 mm diameter needle. Such nanocomposite hydrogels were used to write ‘NPU’ through the syringe, and the different line segments of the ‘NPU’ could heal together into a whole structure through the self-healing performance (Fig. 2f). Under normal circumstances, the inherent elasticity of hydrogel limited its application environment. However, the combination of injectability and self-healing properties of hydrogel can make the hydrogel have the characteristics of in situ molding, which is convenient for various operating scenarios.

Stability and degradation

The stability and degradation tests of hydrogels were showed in figure S5 and S6. The introduction of laponite significantly improved the stability of the hydrogels, and the stability of the hydrogel also increases with the grafting rate of modified polyacrylic acid. In addition, NCgel1 showed glucose-responsiveness. The NCgel1 was completely dissociated after 40 min immersion in a 2 mg/mL glucose solution, this means that these nanocomposite hydrogels have a good application in the biomedical field (Fig. S5c). According to the experimental data, NCgel1 has the best stability. In the following process of adsorbing pollutants by the hydrogel, it is necessary to ensure that the hydrogel can exist stably to avoid secondary pollution to the environment. So only NCgel1 was used to adsorb cationic organic dyes and metal ions.

Morphology

Figure 3 showed the morphology of the hydrogels and nanocomposite hydrogels, namely gel5, NCgel5, gel2.5, NCgel2.5, and gel1, NCgel1, respectively. With same laponite content, the network structure of the hydrogel became denser and the internal pore size was smaller with the increase in the 2-aminophenylboronic acid grafting rate (Fig. 3b, d, f). More 2-aminophenylboronic acid side chains appeared in the polyacrylic acid, more borate ester bond would form between polyacrylic acid and poly(vinyl alcohol) polymer chains, so the cross-linking density was greater. In addition, the comparison between Fig. 3e, f indicated the hydrogels containing laponite had a better network structure compactness, which indicated that laponite might act as a cross-linking point and promote the intertwining of polymer networks (Liu et al. 2020). Figure 3l showed the TEM of laponite within the NCgel1. For a single laponite, its diameter was distributed in 10–50 nm (Yap et al. 2020; Abdullah et al. 2021). The particle size analysis of laponite from dynamic light scattering also showed that the size was mainly distributed below 100 nm (Fig. S7). As for large particles over 100 nm, agglomeration of laponite may exist in water, which causes the size to become larger.

Fig. 3
figure 3

SEM picture of the three-dimensional network structure of hydrogels. a gel5; b NCgel5; c gel2.5; d NCgel2.5; e gel1; f NCgel1. g, h Nanocomposite hydrogels (NCgel1) adsorption test on organic dyes. The absorbance of the methylene blue solution at 665 nm during the adsorption by NCgel1 (g) and the absorbance of malachite green solution at 625 nm during the adsorption of by NCgel1 (h); i NCgel1's adsorption of Cu2+,Cd2+,Pb2+ and Fe3+ over time. The adsorption reaches equilibrium at around 60 min; j Selective adsorption of hydrogels in four ionic mixed solutions; k Selective adsorption of hydrogel at mixing methylene blue with different ions (n = 3); l The TEM image of laponite within the NCgel1

Adsorption of organic dyes

The adsorption of methylene blue and malachite green is determined by measuring the absorbance of the solution against time (Figs. 3a, b and S8). After putting NCgel1 into the dye solution for 4 h, 63% of methylene blue and 49% of malachite green was quickly removed from the solution phase according to the absorbance value, respectively. After 28 h treatment, 71% of methylene blue and 81% of malachite green were removed and trapped into the gel. Under the condition of pH 7, the maximum adsorption capacity of NCgel1 for methylene blue and malachite green were 355 mg/g and 405 mg/g. Laponite is a sheet structure with more negative charges, and its synergy with polyacrylic acid can promote the adsorption of cationic dyes (Fig. 1c).

We selected a part of typical hydrogels for organic dye (and copper ions) adsorption to comparison (Table 1 and Table S1). At present, the adsorption of dyes by hydrogels is performed after lyophilization, in which the adsorption process is accompanied by the swelling of the hydrogel. For in situ synthesized hydrogels, the adsorption was difficult to reach a high level. And the improvement of its adsorption effect was often accompanied by an increase in cost. The nanocomposite hydrogel (NCgel1) in this work cost less and synthesis simple. And it did not need to undergo the lyophilization step before adsorption nor a shaking process during the adsorption process. After putting the gel into the solution, about 65% of the dye can be quickly absorbed into the gel at the bottom of the beaker within 4 h (Figs. 3a, b). When the samples were kept in the tube for 24 h and centrifuged (1500 rpm, 5 min), the hydrogel sticks to the bottom of the centrifuge tube, and the wastewater turned almost clear (Fig. S8a). We also found that the NCgel1 could still adsorb methylene blue at acidic and basic conditions, especially when pH is 9.0, the adsorption efficiency is similar as pH 7.0 (Fig. S8c). The Zeta potential of laponite showed that the laponite nanoparticle possessed permanent negative charge even under acidic conditions (Fig. S9). Therefore, although the negative charges of carboxyl groups on polyacrylic acid were shielded under acidic condition, the hydrogel still possessed a large number of negative charges due to the existence of laponite, which ensured the adsorption capacity of hydrogel to the positively charged metal ions and dyes. Under neutral or alkaline conditions, the combined effect of negatively charged carboxyl groups and laponite further improved the adsorption capacity of the hydrogel.

Table 1 Comparison of nanocomposite hydrogel (NCgel1) with previously reported hydrogels

Adsorption of metal ions

The heavy metal adsorption of NCgel1 was tested by directly immersing into the copper ion (Cu2+ from CuSO4), cadmium ion (Cd2+ from CdCl2), lead ion (Pb2+ from Pb(NO3)2), and iron ion (Fe3+ from FeCl3) solution. With time, the hydrogel turned blue gradually due to the adsorption of copper ions (Fig. S10). The maximum adsorption of Cu2+, Cd2+, Pb2+ and Fe3+ by NCgel1 at 60 min is as high as 259.1 mg/g, 243.4 mg/g, 217.4 mg/g, and 166.2 mg/g, respectively, according to the tests taken with gels of about 0.2 g, which proves the application value in removing heavy metal ions from wastewater (Fig. 3i). When the four ionic solutions are mixed, the hydrogel exhibits different adsorption effects (Fig. 3j). NCgel1 has the highest selective adsorption for Pb2+ and the lowest selective adsorption for Cd2+. When methylene blue is mixed with metal ions, NCgel1 showed stronger adsorption to cationic organic dyes (Fig. 3k).

The polyacrylic acid chain in the hydrogel mainly plays a role in the adsorption of heavy metal ions. Due to the large negative charge in the polyacrylic acid chain, it has a strong adsorption effect on heavy metal cations through electrostatic interactions (Soares et al. 2020) (Scheme S3). In addition, we evaluated the biocompatibility of the hydrogel, please see the supplementary material for details (Figs. S11, S12, S13).

Conclusion

In summary, the nanocomposite hydrogels were successfully prepared, which had good self-healing performance and injectability. At the same time, this hydrogel could hold the integrity in a relatively wide range of pH (pH from 2 to 9) by employing dynamic cross-linking between poly(vinyl alcohol) and 2-aminophenylboronic acid. In addition, the hydrogel had good biocompatibility, and it can quickly and effectively adsorb cationic organic dyes and heavy metal ions from model wastewater. In 28 h, the nanocomposite hydrogel can effectively remove 71% of methylene blue and 81% of malachite green. When the nanocomposite hydrogel is synthesized in situ, the adsorption of methylene blue and malachite green is as high as 355 mg/g and 405 mg/g. Furthermore, the maximum adsorption of Cu2+, Cd2+, Pb2+, and Fe3+ by NCgel1 at 60 min is as high as 259.1 mg/g, 243.4 mg/g, 217.4 mg/g, and 166.2 mg/g, respectively. It is worth mentioning that the raw materials of nanocomposite hydrogel were cheap and the preparation process was simple. Therefore, this multifunctional nanocomposite hydrogel which can adapt to complex pH environments has great application prospects in the fields of wastewater treatment, as well as other environmental and biomedical engineering in the future.