You should use wp_enqueue_script to add the script. The documentation contains information about the function and how it should be used and some helpful examples.
Basically, you will need to add something like this to the functions.php
file:
function myextension_enqueue_scripts() {
wp_enqueue_script(
'myextension-angular',
plugins_url( '/assets/js/angular.min.js' , __FILE__ ),
// If you are working on a theme, not a plugin,
// replace the above line with this:
// get_stylesheet_directory_uri() . '/assets/js/angular.min.js',
array( 'jquery' )
);
wp_enqueue_script(
'myextension-angular-custom',
plugins_url( '/assets/js/angular-custom.js' , __FILE__ ),
// If you are working on a theme, not a plugin,
// replace the above line with this:
// get_stylesheet_directory_uri() . '/assets/js/angular-custom.js',
array( 'jquery', 'myextension-angular' )
);
wp_enqueue_script(
'myextension-add-to-cart-variation',
plugins_url( '/assets/js/add-to-cart-variation.min.js' , __FILE__ ),
// If you are working on a theme, not a plugin,
// replace the above line with this:
// get_stylesheet_directory_uri() . '/assets/js/add-to-cart-variation.min.js',
array( 'jquery', 'myextension-angular' )
);
}
add_action( 'wp_enqueue_scripts', 'myextension_enqueue_scripts' );
Edit: I thought the file angular-custom.js
contained angular, however, I just recognized you split the code into the two files and don’t even include angular. I adapted the code to include a third file, angular.min.js
, which you need to download and add.